2

所以我试图将 ScatterViewItem 从 1 点移动到另一个点。我试过使用 PointAnimation。但是,动画完成后,我无法将项目从 To 点移动。我可以旋转该项目并对其进行缩放,但由于某种原因无法移动它。

这是从 1 点到下一个点的直线运动。我应该使用 PointAnimation 还是有更好的方法?谢谢我在 C# 中做这个

我的点动画代码:

        oPointAnimation = new PointAnimation();
        oPointAnimation.From = new Point(439, 113);
        oPointAnimation.To = new Point(139, 160);

        oPointAnimation.Duration = TimeSpan.FromSeconds(4);
        oPointAnimation.Completed += new EventHandler(oPointAnimation_Completed);
        theCard.BeginAnimation(ScatterViewItem.CenterProperty, oPointAnimation);
4

2 回答 2

1

我猜你需要使用 POintAnimation 的 FillBehaviour 来 FillBehavior="Stop"

于 2009-10-07T22:30:39.730 回答
1

尽管您已经有了一个公认的答案,但我想在这里补充一点。

即使将 FillBehavior 设置为 Stop,在某些情况下它也不起作用。我相信它与设置为 SnapshotAndReplace的HandoffBehavior结合使用。在这些情况下,我所做的是以编程方式在该依赖项属性上使用第二个参数启动一个新动画(使用BeginAnimation )。null

// Remove all animations for the Opacity property on the myElement element 
myElement.BeginAnimation(UIElement.OpacityProperty, null)

这有效地清除了该依赖属性的所有动画,您可以自由地为其分配新值。

于 2009-12-02T09:41:10.323 回答