如何避免/阻止系统绘制/重绘/刷新/绘制 WPF 窗口
我有一个带有 Visual C# 的应用程序 WPF(使用 Visual Studio 2010),我想在 WPF 窗口本身上绘制 OpenGL 场景。至于OpenGL drawinf本身,我能够毫无问题地绘制它,这意味着,我可以从WPF主窗口本身创建GL渲染上下文(没有额外的OpenGL控制,WPF窗口内没有win32窗口),使用GL命令并使用交换缓冲区(所有这些都是在 dll 内完成的 - 使用 C - 我自己创建)。然而,例如,当我调整窗口大小时,我会遇到恼人的闪烁。我重写了 OnRender 方法以使用 opengl 重新绘制,但在此之后,窗口将使用背景颜色重新绘制。系统可能会自动重绘它。使用 WindowForms,我可以防止系统自动重绘(将某些 ControlStyles 定义为 true 或 false,例如 UserPaint = true、AllPaintingInWmPaint = true、Opaque = true、ResizeRedraw = true、DoubleBuffer = false),但是,除了将 Opacity 设置为1,我不知道如何用WPF来做这一切。我希望重写 OnRender 且内部不进行任何操作可以避免重绘,但不知何故系统仍然绘制背景。
有谁知道如何防止系统重绘窗口?
谢谢您的时间
I have an Application WPF with Visual C# (using visual studio 2010) and I want to draw OpenGL scenes on the WPF window itself. As for the OpenGL drawinf itself, I'm able to draw it w/o problems, meaning, I can create GL render context from the WPF main window itself (no additional OpenGL control, no win32 window inside WPF window), use GL commands and use swapbuffer (all this is done inside a dll - using C - I created myself). However, I have an annoying flickering when, for example, I resize the window. I overrided the OnRender method to re-draw with opengl, but after this, the window is redraw with the background color. It's likely that the system is automatically redrawing it. With WindowForms I'm able to prevent the system to redraw automatically (defining some ControlStyles to true or false, like UserPaint = true, AllPaintingInWmPaint = true, Opaque = true, ResizeRedraw = true, DoubleBuffer = false), but, aside setting Opacity to 1, I don't know how to do all that with WPF. I was hoping that overriding OnRender with no operations inside it would avoid redrawin, but somehow the system still draw the background.
Do anyone know how to prevent system to redraw the window?
Thx for your time
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试将窗口的背景设置为空:
您也可以尝试这个。
Try setting the Background of the window to null:
You can also try this.