views:

186

answers:

2

Given a WPF window, which may or may not have animations, I'd like to wait until they are all done before continuing processing. Is there a generic way to do this. Currently I can do something like this:

void WaitForAnimation(Storyboard storyboard)
{
    WaitUntil(() => storyboard.GetCurrentState() == ClockState.Stopped);
}

But this assumes I know the storyboards or have some way of finding them. Is there a way of doing that?

A: 

A suggestion is that use Storyboard.Completed event to find out the completion of each story board.

Kishore Kumar
Yes, but how do you get all the relevant storyboards?
Ray
gud question. let me search and if i get something useful i will let you know. pls update me if you get something.
Kishore Kumar
A: 

Why not just give your storyboards a x:Name and put them into a collection in codebehind? How many of them have you got?

majocha
This is a very generic problem. I am just given a window. I don't know how many storyboards there will be--if any.
Ray
It is quite complicated then. A class inheriting from window may have storyboards created in codebehind as private properties or local variables. It can even animate without storyboards at all. To get a more general control of animations in your base class you'll have to enforce some contract. For example: Animate only using storyboards as resources - then it is easy to retrieve in code all storyboards with FindResource and check their state.
majocha