WPF 执行完一段动画后再关闭窗口
纠结了一天了,也许是还对这个wpf有点陌生,想要执行一个关闭动画再真正关闭窗口,找到一87的方法,比之加个延迟让动画执行完好多了,原文在这http://www.cnblogs.com/Watson/archive/2012/05/27/2519896.html
bool isclose = false; protected override void OnClosing(System.ComponentModel.CancelEventArgs e) { base.OnClosing(e); if (!isclose) { windowout_BeginStoryboard.Storyboard.Completed += delegate { isclose = true; this.Close(); }; windowout_BeginStoryboard.Storyboard.Begin(); e.Cancel = true; } else { e.Cancel = false; } }
这样就十分完美了