Hi I am currently trying to create a sequence of animations using a single storyboard. I have it working however, the two animations in this storyboard don't seem to follow the begin time or duration ive set. They run over each other resulting in part of the animation being hidden.
From my testing its only the DoubleAnimation which doesnt seem to end when it should as will continue to stay active until the entire duration of the storyboard is finished.
Below is the code i have.
private void SetUpAnimation()
{
animation1 = new DoubleAnimation
{
From = 0.0,
To = 1.0,
Duration = new Duration(TimeSpan.FromSeconds(2.0)),
BeginTime = TimeSpan.FromSeconds(0.5),
};
animation1.Completed += Animation1_Completed;
Storyboard.SetTarget(animation1, Splash);
Storyboard.SetTargetProperty(animation1, new PropertyPath("Opacity"));
animatin2Visibility = new ObjectAnimationUsingKeyFrames {
KeyFrames = new ObjectKeyFrameCollection
{
new DiscreteObjectKeyFrame
{
KeyTime = TimeSpan.FromSeconds(3.5),
Value = Visibility.Visible,
}
,
new DiscreteObjectKeyFrame
{
KeyTime = TimeSpan.FromSeconds(4.5),
Value = Visibility.Hidden
}
},
};
animatin2Visibility.Completed += Animatin2Visibility_Completed;
Storyboard.SetTarget(animatin2Visibility, Polar);
Storyboard.SetTargetProperty(animatin2Visibility, new PropertyPath("Visibility"));
myStoryboard = new Storyboard();
myStoryboard.Children.Add(animation1);
myStoryboard.Children.Add(animatin2Visibility);
myStoryboard.Duration = new Duration(TimeSpan.FromSeconds(5.0));
}
I am using the animaition1.completed to turn the visiblity of it to hidden but this doesnt trigger at the correct time
private void Animation1_Completed(object sender, EventArgs e)
{
Splash.Visibility = Visibility.Hidden;
}
The xaml itself is barebones just is a simple user control with currently two images