Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Animation: Detect if any animation is in process?

Tags:

c#

animation

wpf

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.
like image 795
Cameron Peters Avatar asked Mar 24 '11 17:03

Cameron Peters


1 Answers

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.

like image 162
Brent Stewart Avatar answered Nov 14 '22 21:11

Brent Stewart