如何使调整 WPF 窗口大小时不那么“滞后”?
我对 WPF 世界比较陌生,我立即注意到的一件事是,当您调整窗口大小时,窗口内容的绘制是多么滞后。 例如,如果窗口边缘有滚动条,则这些滚动条在缩小时将部分隐藏,并且在放大时它们与窗口边框之间有空间。
即使在 Visual Studio 中创建的空 WPF 项目中也会发生这种情况。 更糟糕的是,背景也会发生这种情况,放大时您可以看到窗口后面的东西(其他窗口、桌面壁纸等)泄漏出来。
起初,我认为这是 WPF 的一个丑陋的限制,因为本机或 WinForms 应用程序可以很好地调整大小(如果编写正确)。 但是,当我查看 Expression Blend 时,窗口背景保持不透明(尽管窗口内容仍然滞后)。 他们如何防止所描述的问题以及是否有任何方法可以改进调整大小以使其更接近本机/WinForm GUI?
I am relatively new in the WPF world and one thing I immediately noticed is how laggy the window content is drawn when you resize a window. For example if you have scrollbars at the window edges those scrollbars will be partly hidden while shrinking and have space between them and the window border when enlarging.
This even happens with an empty WPF project created in Visual Studio. What's even worse is that it also happens with the background and you can see stuff behind the window (other windows, desktop wallpaper, etc.) leak through when enlarging.
At first I thought that it's an ugly limitation of WPF seeing that native or WinForms applications resize just fine (if written properly). But when I look at Expression Blend the window background stays opaque (though the window content still lags behind). What do they do to prevent described problem and are there any ways to improve resizing to more approximate native/WinForm GUIs?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这里很好地解释了延迟的原因
The reason of lags is nicely explained here
您运行的是没有 SP1 的 Vista 吗? 据我所知,这是一个常见问题,应该已经得到解决。
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/3960d6a6-e873-455c-9ddc-1e2dd32e090b/
Are you running Vista without SP1 ? From what I have read, this was a common issue that is supposed have been fixed..
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/3960d6a6-e873-455c-9ddc-1e2dd32e090b/
我自己没有看到这种行为。 我在 vista x64 sp1 和/或运行 xp x32 sp3 的虚拟 PC 上进行开发。 Wpf 使用 directx,这可能是您的显卡/机器吗? 尝试在 diff 机器上运行您的应用程序,看看是否有相同的结果。
I'm not seeing this behavior, myself. I develop on vista x64 sp1 and/or a virtual pc running xp x32 sp3. Wpf uses directx, could it be your video card/machine? Try running your app on a diff machine and see if you have the same results.
我也遇到了同样的问题,即调整大小时界面滞后。 我怀疑延迟的原因是它正在调整 direct X 中的底层帧缓冲区的大小,这从来都不是特别快。 但我不确定你能做些什么。
I have the same issue with the interface lagging while resizing. I suspect that the reason for the lag is it is resizing the underlying frame buffers in direct X which is never particularly fast. I am not sure what you can do about it though.
我也一直在寻找有关这个问题的信息。 我只是认为这是一个 Windows“功能”,一些勇敢的微软程序员认为它会很酷。 我希望能够将其关闭,以便窗口大小调整实际上会跟随我的鼠标,而不是滞后然后超调。 咕噜。
I've been looking for information on this issue as well. I just thought it was a windows "feature" that some intrepid microsoft programmer thought would be cool. I was hoping to be able to turn it off so that window resizes would actually follow my mouse, instead of lagging and then overshooting. Grr.