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 woul开发者_运维技巧d 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.
精彩评论