2017-04-04 122 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