1

我正在尝试在 wpf 中移动图像。图像应遵循椭圆作为路径。动画完成后,应立即重新开始。(例如一个行星旋转)

如果我是对的,我应该使用 DoubleAnimation。

问题是我应该向 DoubleAnimation 标签写什么。

这是我到目前为止编写的代码:

    <Image Source="t:\\moon.jpg" Width="50" Height="50">
        <Image.Triggers>
            <EventTrigger>
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation>

                        </DoubleAnimation>
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>
        </Image.Triggers>
    </Image>
4

1 回答 1

0

我认为你应该使用PathAnimation而不是 DoubleAnimation。

来自 MSDN 的示例:

<EventTrigger RoutedEvent="Button.Loaded">
      <BeginStoryboard>
        <Storyboard>
          <MatrixAnimationUsingPath
          Storyboard.TargetName="ButtonMatrixTransform"
          Storyboard.TargetProperty="Matrix"
          DoesRotateWithTangent="True"
          Duration="0:0:5" 
          RepeatBehavior="Forever" >
            <MatrixAnimationUsingPath.PathGeometry>
              <PathGeometry 
                Figures="F1 M 147.5,0.5C 228.686,0.5 294.5,24.4528 294.5,54C 294.5,83.5472 228.686,107.5 147.5,107.5C 66.3141,107.5 0.5,83.5472 0.5,54C 0.5,24.4528 66.3142,0.5 147.5,0.5 Z" 
                PresentationOptions:Freeze="True" />
            </MatrixAnimationUsingPath.PathGeometry>
          </MatrixAnimationUsingPath>
        </Storyboard>
      </BeginStoryboard>
    </EventTrigger>

您可以在此处了解路径标记语法

于 2013-04-02T13:09:15.580 回答