WPF椭圆路径

时间:2013-04-02 13:05:35

标签: wpf path ellipse

我正在尝试在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>

1 个答案:

答案 0 :(得分: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>
  

您可以了解路径标记语法 here