2012-02-08 17 views
8

¿Hay algún evento que se desactive cuando termine WPF Animation?¿Hay algún evento que se desactive cuando termine la animación WPF?

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); 
} 

Respuesta

16

Sí, hay.

the Completed Event (MSDN)


lo que el código se convierte en:

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); 

} 
Cuestiones relacionadas