.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
Howdy,

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
moment...

See how you go,

Cheers
--
http://www.learnexpressionstudio.com
http://www.expressionblend.com
http://www.x-coders.com
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
Howdy..

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

http://expressionblend.com/files/folders/beta_1_projects/entry30.aspx

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...

Cheers
--
http://www.learnexpressionstudio.com
http://www.expressionblend.com
http://www.x-coders.com