【问题标题】:WPF ellipse pathWPF椭圆路径
【发布时间】:2013-04-02 13:05:34
【问题描述】:

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

【问题讨论】:

    标签: wpf path ellipse


    【解决方案1】:

    我认为你应该使用 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

    【讨论】:

    • 在 PathGeometry 数字中,数字是我想的点坐标。但是这些字母代表什么? (M, C) ?此外,这是一条正弦曲线。
    • @MandyTaylor 我编辑了我的帖子。不用担心这些值,它们可以使用 Expression Design 等工具生成
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-28
    • 1970-01-01
    • 2016-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多