我有一個包含橢圓的用戶控件。將橢圓轉換爲右側直到它部分位於其父控制之外。當父列寬設置爲GridUnitType.Star時Silverlight剪裁UserControl
我把用戶控件放到3列網格的中間列。
如果我將列寬設置爲GridUnitType.Auto,我可以看到溢出列的橢圓。如果我將列寬設置爲GridUnitType.Star,那麼橢圓仍然會溢出列,但現在它被裁剪爲列寬。
我需要使用GridUnitType.Star平均分配列寬,但不希望任何轉換的內容被剪切。
我已經包含下面的示例代碼。任何幫助,將不勝感激。
用戶控件(含橢圓)
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="GridWidthTest.UserControl1">
<Grid x:Name="LayoutRoot" Background="Green">
<Ellipse Fill="#FFF40404" Stroke="Black" Grid.Column="1" Width="400" Height="400" RenderTransformOrigin="0.5,0.5">
<Ellipse.RenderTransform>
<TransformGroup>
<TranslateTransform X="200"/>
</TransformGroup>
</Ellipse.RenderTransform>
</Ellipse>
</Grid>
父控制(含有網格)
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:GridWidthTest" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Class="GridWidthTest.MainPage"
Width="640" Height="480" mc:Ignorable="d">
<Grid x:Name="LayoutRoot" Background="White">
<Grid ShowGridLines="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<local:UserControl1 Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/>
</Grid>
</Grid>
巧妙!這很好地工作。 – McGarnagle 2014-10-22 22:45:11