我有一个包含椭圆的用户控件。将椭圆转换为右侧直到它部分位于其父控制之外。当父列宽设置为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