2012-02-08 34 views
8

WPFアニメーションの終了時に発生するイベントはありますか?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); 
} 

答えて

16

はいあります。

the Completed Event (MSDN)


だからあなたのコードは次のようになります。

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

} 
関連する問題