【问题标题】:Animation run forward and then reverse back to original state动画向前运行,然后返回原始状态
【发布时间】:2012-01-13 18:00:17
【问题描述】:

是否有任何简单的方法可以正常运行基于 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?

例如,您可能有一个椭圆从左向右移动的动画,并且您希望它在结尾处移回开始的左侧:

【问题讨论】:

  • 最好在一次触发运行中进行,但如果有更简单的方法可以在两次运行中进行,我也希望看到。

标签: .net wpf c#-4.0 animation .net-4.0


【解决方案1】:

您是否尝试过将AutoReverse 设置为true?

【讨论】:

  • 这正是我一直在寻找的,但很高兴看到如何手动反向运行动画,以及(完成后)。
  • @MichaelGoldshteyn:我也尝试过一次,但没有找到简单的方法,所以我最终复制了 SB 并将所有 To 值更改为它们的原点。也许我忽略了一些东西......
  • @MichaelGoldshteyn:哦,是的,可视状态管理器可能是一个选项 (related question)。
【解决方案2】:
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?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-08
    • 2011-12-16
    • 1970-01-01
    • 1970-01-01
    • 2019-01-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多