1

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

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

在此处输入图像描述

4

2 回答 2

2

据我所知,开箱即用是不可能的,因为您试图PointPointCollection. 您真正需要的是PointCollectionAnimationWPF 不提供的 . 然而,了不起的 Charles Petzold 前段时间写了这篇文章,向您展示了如何去做。

于 2011-11-01T09:05:55.033 回答
0

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

<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>
于 2017-09-24T08:07:27.203 回答