Is there an event that fires when WPF animation finishes?

Is there an event that fires when WPF animation finishes?

void HideDefaultScreenImageTimer_Tick(object sender, EventArgs e) { HideDefaultScreenImageTimer.Stop(); var doubleAnimation = new DoubleAnimation(1, 0, new Duration(TimeSpan.FromSeconds(0.45))); DefaultScreenImage.BeginAnimation(UIElement.OpacityProperty, doubleAnimation); // I need some event when an animation ENDS and within that event I want to remove // Image (DefaultScreenImage) from Canvas. MainCanvas.Children.Remove(DefaultScreenImage); } 
+8
c # wpf xaml
source share
1 answer

Yes there is.

Completed Event (MSDN)


So your code will look like this:

 void HideDefaultScreenImageTimer_Tick(object sender, EventArgs e) { HideDefaultScreenImageTimer.Stop(); var doubleAnimation = new DoubleAnimation(1, 0, new Duration(TimeSpan.FromSeconds(0.45))); doubleAnimation.Completed += (sender, eArgs) => MainCanvas.Children.Remove(DefaultScreenImage); DefaultScreenImage.BeginAnimation(UIElement.OpacityProperty, doubleAnimation); } 
+16
source share

All Articles