views:

837

answers:

1

Is it possible to create a storyboard where the second half repeates, but the first half doesn't? Or alternatively, can I cause one storyboard to start after another finishes, all in xaml?

+2  A: 

I don't think you can work with animations just in XAML/Blend you need to begin them in code anyways.

StoryBoard1.Begin();

But the code to start another animation just as the first one finishes is quite simple:

First you subscribe to the Completed events in code:

this.Storyboard1.Completed += new EventHandler(Storyboard1_Completed);
this.Storyboard2.Completed += new EventHandler(Storyboard2_Completed);
this.Storyboard1.Begin();

Then in the respected eventhandlers if Storyboard1 finished you start storyboard2 and vice versa.

private void Storyboard2_Completed(object sender, EventArgs e){
  this.Storyboard1.Begin();
}

private void Storyboard1_Completed(object sender, EventArgs e)
{
 this.Storyboard2.Begin();
}

To add the eventhandlers you just have to type Storyboard.Completed += and then hit tab twice and it will generate the needed methods.

texmex5