2012-01-13 87 views
1

有没有简单的方法可以正常运行WPF故事板动画,然后反向运行以将所有内容都返回到原始状态?动画向前运行,然后又回到原始状态

最好,我想以编程方式做到这一点:

Storyboard sb=new Storyboard(); 

... 

sb.Begin(); 

// Now how to do I run sb in reverse, to move things to where they were 
// before the sb started? 

例如,你可能有一个动画,其中由一个椭圆左向右移动,你想它在搬回到最后左边,那里开始:

enter image description here

+0

在一次触发的一两次? – 2012-01-13 18:01:41

+0

在一次触发运行会更好,但如果有更容易的方法做到两个我也想看到。 – 2012-01-13 18:03:33

回答

5

你试过设置AutoReversetrue呢?

+0

这正是我一直在寻找的内容,但是看到如何以手动方式反向运行动画(在完成之后)也会很好。 – 2012-01-13 18:15:30

+0

@MichaelGoldshteyn:我曾试过这样一次,但没有找到一个简单的方法,所以我最终复制了SB并将所有“To”值更改为其原点。也许我忽略了一些东西虽然... – 2012-01-13 18:18:42

+1

@MichaelGoldshteyn:噢,可视状态管理器可能是一个选项([相关问题](http://stackoverflow.com/questions/4665529/how-to-reverse-wpf-storyboard -动画))。 – 2012-01-13 18:22:39

0
Storyboard sb=new Storyboard(); 
sb.AutoReverse=true; 
... 

sb.Begin(); 

// Now how to do I run sb in reverse, to move things to where they were 
// before the sb started? 
相关问题