Is there any event that fires when WPF animation ends?

前端 未结 1 1566
野性不改
野性不改 2021-02-14 03:21

Is there any event that fires when WPF Animation ends?

void HideDefaultScreenImageTimer_Tick(object sender, EventArgs e)
{
         


        
1条回答
  •  星月不相逢
    2021-02-14 04:07

    Yes there is.

    The Completed Event (MSDN).


    So your code becomes:

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

    0 讨论(0)
提交回复
热议问题