【问题标题】:How to animate polyline points using doubleanimation / pointanimation如何使用 doubleanimation / pointanimation 为折线点设置动画
【发布时间】:2011-12-19 07:29:17
【问题描述】:

假设我有一条折线,并且我希望只使用动画将折线的末端从 A 移动到 B。我该怎么做呢?

p/s:如果建议是针对折线而不是针对其他控件(例如路径等),我仍然会更喜欢 :)

【问题讨论】:

  • 目前我将使用 transform 属性,但我仍然会感谢有关如何使用点进行操作的任何建议。
  • 你使用msdn.microsoft.com/en-us/library/…RotationTransform吗?
  • @Tigran 是的,我目前正在使用它,但我意识到我不能使用它。起点是不断移动的。如果我使用旋转,它会缺乏灵活性,因为起点将永久位于某个位置或直到调用另一个事件。 (我很抱歉解释不好,但这是我能传达的最好的)

标签: c# wpf shapes kinect polyline


【解决方案1】:

据我所知,开箱即用是不可能的,因为您试图在PointCollection 中为Point 设置动画。您真正需要的是PointCollectionAnimation,而 WPF 不提供。然而,很棒的 Charles Petzold 不久前写了this article,向您展示了如何去做。

【讨论】:

    【解决方案2】:

    由于接受的答案中提到的链接不再起作用,所以我发布了我的方法。

    <Path Stroke="Red">
                <Path.Data>
                    <GeometryGroup>
                        <LineGeometry x:Name="G1" StartPoint="100,100" EndPoint="100,0"/>
                    </GeometryGroup>
                </Path.Data>
                <Path.Triggers>
                    <EventTrigger RoutedEvent="Loaded">
                        <BeginStoryboard>
                            <Storyboard>                            
                                <PointAnimationUsingPath Storyboard.TargetName="G1" Storyboard.TargetProperty="EndPoint">
                                    <PointAnimationUsingPath.PathGeometry>
                                        <PathGeometry Figures="M 100,0 C 150,50 200,75 250, 100" />
                                    </PointAnimationUsingPath.PathGeometry>
                                </PointAnimationUsingPath>
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                </Path.Triggers>
            </Path>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-08
      • 2019-12-09
      • 1970-01-01
      • 2020-12-08
      相关资源
      最近更新 更多