I have 2 custom controls in my silverlight application and each one is having its own animations. I want to play all of the animations in order but when they play at the same time, the animations are not playing properly. How can I put some delay between them?
private void button1_Click(object sender, RoutedEventArgs e)
{
Dispatcher.BeginInvoke(() => {
myCustomControl1.Play();
Thread.Sleep(200);
Dispatcher.BeginInvoke(() => { myCustomControl2.Play(); });
}
I’m assuming your controls are using a StoryBoard to play the animations. StoryBoard has a “Completed” event that fires after it completes running. So, you could do something like:
What you can then do is chain your animations together:
Now we can guarantee that animation 2 will always happen after animation 1.