WPF动画结束时是否会触发任何事件? [英] Is there any event that fires when WPF animation ends?
本文介绍了WPF动画结束时是否会触发任何事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
WPF动画结束时是否会触发任何事件?
Is there any event that fires when WPF Animation ends?
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);
}
推荐答案
是的.
因此您的代码变为:
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);
}
这篇关于WPF动画结束时是否会触发任何事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文