如何捕捉结束的调整大小窗口? [英] How to catch the ending resize window?
本文介绍了如何捕捉结束的调整大小窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在 WPF 中捕获事件 endresize.
I need catch the event endresize in WPF.
推荐答案
WPF 不提供仅在调整大小过程结束时触发的事件.SizeChanged 是唯一与窗口大小调整相关的事件 - 它会在调整大小过程中多次触发.
WPF doesn't provide an event that solely fires at the end of the resize process. SizeChanged is the only event associated with Window resizing - and it will fire multiple times during the resizing process.
当 SizeChanged 事件触发时,一个总的技巧是不断地设置一个计时器滴答作响.然后计时器将不会有机会在调整大小结束之前打勾,然后进行一次性处理.
A total hack would be to constantly set a timer ticking when the SizeChanged event fires. Then timer will not get a chance to tick until resizing ends and at that point do your one time processing.
public MyUserControl()
{
_resizeTimer.Tick += _resizeTimer_Tick;
}
DispatcherTimer _resizeTimer = new DispatcherTimer { Interval = new TimeSpan(0, 0, 0, 0, 1500), IsEnabled = false };
private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e)
{
_resizeTimer.IsEnabled = true;
_resizeTimer.Stop();
_resizeTimer.Start();
}
void _resizeTimer_Tick(object sender, EventArgs e)
{
_resizeTimer.IsEnabled = false;
//Do end of resize processing
}
这篇关于如何捕捉结束的调整大小窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文