简体   繁体   中英

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.

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM