[英]WPF Animation: Detect if any animation is in process?
Is there a quick way to determine if any animation in a WPF control is processing. 有没有一种快速的方法来确定WPF控件中是否有任何动画正在处理。
I have a treeview where I am animating the expansion of the tree nodes, and I would like to wait until all those animations are complete before scrolling the focused item into view. 我有一个treeview,在其中为树节点的扩展设置动画,我想等到所有这些动画完成后再将聚焦的项目滚动到视图中。 I'd prefer not to track the progress of all my storyboards independently.
我希望不要独立跟踪所有故事板的进度。
Ideally my pseudo code would look something like this: 理想情况下,我的伪代码应如下所示:
myTreeView.ExpandAll(); // I have written this part
while (myTreeView.IsAnimating()) // I need the 'IsAnimating' property or extension method
{
// wait
}
selectedTreeviewItem.BringIntoView(); // I have written this too.
Why not use the storyboard's completed event ? 为什么不使用情节提要的完成事件 ? You will have to either use an event or a different thread, or you will block the UI thread with your while statement and no animations will play.
您将必须使用事件或其他线程,或者使用while语句阻止UI线程,并且不会播放动画。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.