.NET Framework - Storyboard Completed Event

Asked By srya on 07-Jun-07 09:06 AM
I know I can add Completed="myCode" inside a Storyboard tag to run myCode.
However, when the storyboard lives in app.xaml (where I currently have all my
templates) and the code in another page (for instance myPage.xaml.cs), I get
an error..."'MyApp.App' does not contain a definition for 'myCode'." Is there
a way around this? Any help would be appreciated.

BrennonWilliam replied on 08-Jun-07 08:16 AM

You should be able to get a reference to the storyboard in your code file
and add the event handler from there...

Somthing like:

private void Method()
Storyboard ST = this.FindResource("Timeline1") as Storyboard;
ST.Completed += new EventHandler(ST_Completed);

void ST_Completed(object sender, EventArgs e)


You will need to check the syntax, I dont have VS or Blend open at the

See how you go,

srya replied on 08-Jun-07 11:17 AM
Ran into a problem. I get an error that my storyboard can't be found. My
guess is because the storyboard is in the resources of a template, not
directly in the resources of my window. I tried searching for the template
first and casting that to a controltemplate. Then I planned on using
FindResource to find the storyboard, but findresource wasn't available. Any
other suggestions?
BrennonWilliam replied on 08-Jun-07 03:22 PM

I just had a thought (whilst sipping on a nice bourbon and enjoying my
weekly stoggie)... this application might help you...


It is a little old now, but it does basically the same thing, in terms of
finding a storyboard kept in a style or a ControlTemplate....

Let me know if this helps...