【发布时间】:2010-12-24 05:43:15
【问题描述】:
在后面的代码中对依赖属性运行 WPF 动画后,无法再使用 SetValue 设置依赖属性。它们只能通过动画来改变。
我想更改依赖属性,有时通过短动画,有时立即在代码中。
那么如何在动画结束后从依赖属性中移除动画呢?
【问题讨论】:
标签: wpf animation dependency-properties code-behind
在后面的代码中对依赖属性运行 WPF 动画后,无法再使用 SetValue 设置依赖属性。它们只能通过动画来改变。
我想更改依赖属性,有时通过短动画,有时立即在代码中。
那么如何在动画结束后从依赖属性中移除动画呢?
【问题讨论】:
标签: wpf animation dependency-properties code-behind
将动画的 FillBehaviour 设置为 Stop。 然后调用 BeginAnimation。 然后将属性值设置为动画的结束值。
现在,动画结束后,该属性将再次像普通属性一样工作。
【讨论】:
动画结束后(或您希望它停止时):
myButton.Width = myButton.Width; // set current value to the end value of the animation
myButton.ApplyAnimationClock(Button.WidthProperty, null); // remove animation
对于一个真正简单的库,看看http://code.google.com/p/wpf-animation/
【讨论】: