我有一个旋转的图像,当你点击它时,它停止并收集它上面的旋转。但由于某种原因,有时候它会从它被敲击的位置向后(或周围)猛拉。有谁知道如何解决这个问题:
XAML:
<StackPanel>
<StackPanel.Resources>
<Storyboard x:Name="AttackCircleAnimation">
<DoubleAnimation x:Name="combatCircleRotation"
Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)"
Storyboard.TargetName="combatCircleSword" Duration="0:0:1" From="0" To="360" RepeatBehavior="Forever" />
</Storyboard>
</StackPanel.Resources>
</StackPanel>
<Image x:Name="combatCircleSword" RenderTransformOrigin="0.5,0.5" Tap="TapProcessAttack">
<Image.RenderTransform>
<CompositeTransform Rotation="0"/>
</Image.RenderTransform>
</Image>
CODE:
private void TapProcessAttack(object sender, System.Windows.Input.GestureEventArgs e)
{
AttackCircleAnimation.Pause();
CompositeTransform t = combatCircleSword.RenderTransform as CompositeTransform;
spinFinalValue = t.Rotation;
}