I created a few ColorAnimations and want them to run at the same time (whether they run syncronized doesn't matter). Sadly only one of them runs.
storyboard = new Storyboard();
//Animation Auditorium
ColorAnimation SpotLightAnimation = new ColorAnimation();
SpotLightAnimation.To = Color.FromArgb(1, Convert.ToByte(random.Next(0, 255)), Convert.ToByte(random.Next(0, 255)), Convert.ToByte(random.Next(0, 255)));
SpotLightAnimation.Duration = TimeSpan.FromSeconds(3);
SpotLightAnimation.Completed += new EventHandler(storyboard_Completed);
this.RegisterName("MySpotlight", karte.SpotLightAuditorium);
Storyboard.SetTargetName(SpotLightAnimation, "MySpotlight");
Storyboard.SetTargetProperty(SpotLightAnimation, new PropertyPath(SpotLight.ColorProperty));
storyboard.Children.Add(SpotLightAnimation);
//Animation Wohnzimmer
ColorAnimation SpotLightWohnzimmerAnimation = new ColorAnimation();
SpotLightWohnzimmerAnimation.To = Color.FromArgb(1, Convert.ToByte(random.Next(0, 255)), Convert.ToByte(random.Next(0, 255)), Convert.ToByte(random.Next(0, 255)));
SpotLightWohnzimmerAnimation.Duration = TimeSpan.FromSeconds(3);
SpotLightAnimation.Completed += new EventHandler(storyboard_Completed);
this.RegisterName("MySpotLightWonzimmer", karte.SpotLightWohnzimmer);
Storyboard.SetTargetName(SpotLightWohnzimmerAnimation, "MySpotLightWonzimmer");
Storyboard.SetTargetProperty(SpotLightWohnzimmerAnimation, new PropertyPath(SpotLight.ColorProperty));
storyboard.Children.Add(SpotLightWohnzimmerAnimation);
storyboard.Begin(this);
}
void storyboard_Completed(object sender, EventArgs e)
{
(storyboard.Children[0] as ColorAnimation).To = Color.FromArgb(1, Convert.ToByte(random.Next(0, 255)), Convert.ToByte(random.Next(0, 255)), Convert.ToByte(random.Next(0, 255)));
storyboard.Begin(this);
}