的WinForms WPF互操作 - WPF内容没有油漆 [英] Winforms WPF Interop - WPF content fails to paint

查看:294
本文介绍了的WinForms WPF互操作 - WPF内容没有油漆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用ElementHost的显示一个WPF用户控件一个WinForm。每隔50次左右,当窗体加载WPF内容没有油漆。您可以通过WinForm的铬为所有底下看到的。调整窗口得到WPF内容展现出来。

I have a WinForm that uses an ElementHost to display a WPF UserControl. Once every 50 times or so when the form loads the WPF content fails to paint. You can see through the WinForm chrome to whatever is beneath. Resizing the window gets the WPF content to show up.

这是一个已知的问题?任何人都可以提出一个解决办法?

Is this a known issue? Can anyone suggest a workaround?

推荐答案

我们以前打过这些类型的问题。看到这个WPF论坛<一href="http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/a8a5eebc-3d9e-44bb-abe3-8ce0d4e48263/">post对我们的特殊风味的详细信息(我不知道这是否是同一个问题或不)。

We have fought these types of issues before. See this WPF forum post for more info on our particular flavor (I don't know if it is the same issue or not).

这是我们找到的工作的唯一的事情就是为修改的ElementHost

The only thing that we found to work was to change the size of the ElementHost.

_elementHost.Width++;

这是一个完整的黑客攻击,丑,我很尴尬,甚至张贴。但是,没有别的曾经为我们工作。所以,这绝对是一个解决办法。 (GRIN)

It's a complete hack, ugly, and I'm embarrassed to even post it. But nothing else ever worked for us. So, it is definitely a workaround. (Grin)

我们试图变成无效时,刷新和一切我们能想到的...在ElementHost的。我们也尝试InvalidateMeasure,InvalidateArrange和InvalidateVisual在WPF托管的内容。没有运气。

We tried Invalidate, Refresh and everything we could think of ... on the ElementHost. We also tried InvalidateMeasure, InvalidateArrange, and InvalidateVisual on the WPF hosted content. No luck.

如果你找到另一种方式来解决您的问题,我很乐意听到这个消息。

If you find another way to fix your issue, I would love to hear about it.

祝你好运,我知道我已经失去了一些头发就这一个。

Good luck, I know I have lost some hair on this one.

更新1: 我已经提交了另WPF论坛<一href="http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/c221382e-82f1-4736-956a-806dc2a8cb37">post这一点。也许我们可以从微软的回应。当然好像对我的错误。

Update 1: I have submitted another WPF forum post on this. Maybe we can get a response from Microsoft. Sure seems like a bug to me.

更新2: 当我固定上述劈刷新问题...我还有另一个问题要解决,我认为这里值得一提。那就是:有一定的延误,直到屏幕刷新。这使得它看起来像是用户被导航到另一个屏幕(这不是...这是双缓冲缓冲区的内容之外)。我最后不得不手动调用System.Windows.Forms.Control.Refresh()对被托管的ElementHost控制。这样一来,即使暂停还在那里...至少在屏幕上是空白...它看起来并不像用户正在浏览的地方...

Update 2: After I fixed the refresh issue with the above hack ... I still had another problem to solve that I thought worth mentioning here. That is: there was a definite delay until the screen refreshed. This made it seem like the user was navigating to another screen (it wasn't ... it was just the contents of the double buffering buffer). I ended up having to manually call System.Windows.Forms.Control.Refresh() on the Control that was hosting the ElementHost. In this way, even though the pause was still there ... at least the screen was blank ... and it didn't look like the user was navigating somewhere ...

这篇关于的WinForms WPF互操作 - WPF内容没有油漆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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