2017-04-04 62 views
0

我的目的是建立动画复选标记,并为此使用两个矩形。但是我无法正确连接这些矩形(这可以在一个设备上看起来不错,但在另一个分辨率下,设备可以看到该关节)。我的问题是如何将这些矩形的坐标放在代码后面? XAML代码提供以下旋转矩形结点WPF UWP

<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> 
+0

它看起来像你的第一个矩形的顶部缺失。它也有投影吗?你能否也请添加该代码?你只是想在代码中移动两个矩形位置? –

+0

对不起,代码现在被编辑... – cybergogic

回答

0

你可能会遇到布局舍入的问题。关闭母公司Grid中的布局舍入,看看预测/转换是否正常。

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

这不能解决问题,但添加了一些artefacts :) – cybergogic