WPF调整完成 [英] wpf resize complete

查看:155
本文介绍了WPF调整完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我需要在程序上生成一格的背景图像,只需要.1sec。

So I need to procedurally generate a background image for a grid, it only takes .1sec.

因此​​,我可以电汇到SizeChanged事件,但是当调整图表,它会并触发甚至可能30次,所以resize事件滞后了signifigantly。

So I can wire into the SizeChanged event, but then when you resize the chart, it goes and fires the even maybe 30 times a second, so the resize event lags out signifigantly.

有谁知道来连接到调整大小事件和测试天气用做调整的好方法,我试图简单地检查鼠标向上/向下的状态,但是当调整大小事件触发鼠标是pretty的多一直下去。

Does anybody know a good way to wire into the resize event and test weather the use is done resizing, I tried simply checking for the mouse up/down state, but when the resize event fires the mouse is pretty much always down.

推荐答案

在调整大小,你可以开始一个短暂的定时器(比如100毫秒),每个resize在重置计时器从流逝prevent它。当最后一个调整大小发生时,计时器会过去的,你可以画出你的背景图片,然后。

On resize, you could start a short lived timer (say 100 mSec), on each resize reset that timer to prevent it from elapsing. When the last resize happens, the timer will elapse, and you can draw your background image then.

例如:

Timer resizeTimer = new Timer(100) { Enabled = false };

public Window1()
{
    InitializeComponent();
    resizeTimer.Elapsed += new ElapsedEventHandler(ResizingDone);
}

void ResizingDone(object sender, ElapsedEventArgs e)
{
    resizeTimer.Stop();
    GenerateImage();
}

private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
{
    resizeTimer.Stop();
    resizeTimer.Start();
}

这篇关于WPF调整完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆