views:

66

answers:

1

Hey. This is probably a simple question, but how do I know when a Storyboard animation has completed? I'm using .Net 3.0 so maybe that's why, but in my other projects (.net 4), there was a simple Completed event I could handle. What's the way to do it in WPF with .net 3.0? Thanks

edit in response to comments: I guess the error lies elsewhere. I can't access my storyboard from the code-behind.

//storyboardBounce does not exist error is thrown
  storyboardBounce.Completed += new EventHandler(Storyboard_Completed); 

However, if I assign triggers to buttons in Blend, I can access them like this:

 sbDisplayContents_BeginStoryboard.Storyboard.Completed += new EventHandler(Storyboard_Completed);

But since there are many triggers calling the same storyboard, I would have to manually set the event handlers for each one like the above. Is there a reason my storyboard can't be accessed from the code-behind? Or is there a way to have multiple triggers assigned to the same storyboard so that I don't have to handle the Completed event for

 sbDisplayContents_BeginStoryboard...
 sbDisplayContents_BeginStoryboard1...
 sbDisplayContents_BeginStoryboard2...

etc..

Thanks

+1  A: 

The Completed event exists in 3.0... (it's inherited from Timeline)

http://msdn.microsoft.com/en-us/library/system.windows.media.animation.timeline.completed.aspx

Supported in: 4, 3.5, 3.0


UPDATE

If your storyboard is declared in the resources, you can't access it directly in code-behind. You need to call FindResource :

StoryBoard storyboardBounce = FindResource("storyboardBounce") as StoryBoard;
Thomas Levesque
Thanks.I guess the error is elsewhere - I've updated my original post.
Skoder
That's fixed the problem, thanks!
Skoder