旋转矩形连接WPF UWP

时间:2017-04-04 05:34:03

标签: c# wpf xaml windows-phone-8 uwp

我的目的是建立动画复选标记,我使用两个矩形。但是我不能正确地连接这些矩形(这在一个设备上看起来不错,但是在具有另一个分辨率的设备中可以看到关节)。我的问题是如何在代码后面停靠这些矩形的坐标? XAML代码在下面提供

    <Grid x:Name="gridMain">
    <Rectangle x:Name="RectCheck1" HorizontalAlignment="Left" RenderTransformOrigin="1,1" Fill="{Binding Color,ElementName=check}"  Height="18"  Width="50" Visibility="Visible">
            <Rectangle.Projection>
                <PlaneProjection RotationZ="-45" CenterOfRotationX="0" CenterOfRotationY="0" CenterOfRotationZ="0"/>
            </Rectangle.Projection>
            <Rectangle.RenderTransform>
                <CompositeTransform x:Name="RectTrans1" />
            </Rectangle.RenderTransform>
            <Rectangle.Resources>
                <Storyboard x:Name="RectCheck1Draw" Storyboard.TargetName="RectCheck1">
                <DoubleAnimation x:Name="RectAnim1Width" EnableDependentAnimation="True" Storyboard.TargetProperty="Width" From="0" To="50" Duration="0:0:2" RepeatBehavior="1x" />
            </Storyboard>
            </Rectangle.Resources>
        </Rectangle>

    <Rectangle x:Name="RectCheck2" Fill="{Binding Color,ElementName=check}" HorizontalAlignment="Left"  Height="18"   Width="70"  Visibility="Visible">
        <Rectangle.Projection>
            <PlaneProjection RotationZ="45" CenterOfRotationX="0" CenterOfRotationY="0" CenterOfRotationZ="0"/>
        </Rectangle.Projection>

        <Rectangle.RenderTransform>
            <CompositeTransform x:Name="RectTrans2" />
        </Rectangle.RenderTransform>
        <Rectangle.Resources>
            <Storyboard x:Name="RectCheck2Draw" Storyboard.TargetName="RectCheck2">
                <DoubleAnimation x:Name="RectAnim2Width" EnableDependentAnimation="True" Storyboard.TargetProperty="Width" From="0" To="70" Duration="0:0:3" RepeatBehavior="1x" />
            </Storyboard>
        </Rectangle.Resources>

    </Rectangle>
</Grid>

1 个答案:

答案 0 :(得分:0)

您可能遇到布局舍入问题。关闭父Grid中的布局舍入,并查看投影/转换是否正确捕捉。

<Grid UseLayoutRounding="False">
   <Rectangle ...>
   <Rectangle ...>
</Grid>