简体   繁体   English

Winforms WPF Interop - Wpf控件呈现为非活动状态

[英]Winforms WPF Interop - Wpf controls rendered inactive

I have a similar problem to this question regarding painting of wpf controls 我有一个类似的问题,这个问题就WPF控件的画

The application I work on is a rather large Windows forms threaded application with several wpf user controls throughout the application. 我工作的应用程序是一个相当大的Windows表单线程应用程序,在整个应用程序中有几个wpf用户控件。 The problem occurs in a plugin of the application where a third party c++ library is called on a separate thread, WndProc is overriden to get the progress updates from the third party library. 问题出现在应用程序的插件中,在单独的线程上调用第三方c ++库,WndProc被覆盖以从第三方库获取进度更新。 I have yet to determine the exact scenario that causes the problem but similar to the above mentioned question, after a few runs the wpf controls fails to paint and update. 我还没有确定导致问题的确切场景,但类似于上面提到的问题,经过几次运行后,wpf控件无法绘制和更新。

Setting the width of the elementhosts does solve the painting issue for most of the controls but after this all the wpf controls in the application seems to become 'unresponsive' - visually... the progress bars fails to show progress (though the value does change), scrollbars does not respond, selecting an item in the listview does not highlight it(it does get highlighted after resizing and it does actually get selected - you just can see it is selected) the treeviews does not paint after the resizing, it only shows a black background where the treeview should be (though when I click on the items where they should be in the treeview, the events does get trigerred) 设置elementhosts的宽度确实解决了大多数控件的绘制问题,但在此之后,应用程序中的所有wpf控件似乎变得“无响应” - 在视觉上...进度条无法显示进度(尽管值确实发生了变化) ),滚动条没有响应,在列表视图中选择一个项目不会突出显示它(它确实在调整大小后突出显示它实际上被选中 - 你只能看到它被选中)树视图在调整大小后不会绘制,它只是显示树视图应该是黑色背景(虽然当我点击它们应该在树视图中的项目时,事件确实会被触发)

I know I should probably find out the root of the problems that causes this first (its hapening rather randomely and is hard to trap) - allthough putting a breakpoint in the WndProc method does seem to cause it to fail on a regualar base... 我知道我应该找出导致这个问题的根源(它的hapening相当randomely并且很难陷阱) - 虽然在WndProc方法中设置一个断点似乎确实导致它在一个regualar基础上失败...

What I was hoping for is a way to 'reactivate'/refresh all the other controls throughout the application... I am an intermediate wpf, c# developer and dont really know enough yet about the messaging and events that happens in the background to use them effectively ... my thought is that some event or message that tells wpf to redraw must be broken or interrupted or something - how can I determine what is broken and maybe reactivate it?? 我希望的是一种“重新激活”/刷新整个应用程序中所有其他控件的方法......我是一个中间的wpf,c#开发人员,并且还不太了解在后台使用的消息和事件它们有效...我的想法是,某些事件或消息告诉wpf重绘必须被打破或中断或者某些东西 - 我怎样才能确定什么是坏的并且可能重新激活它?

Any advice will be much appreciated... 任何建议将不胜感激......

Thank You 谢谢

It could be that the event that causes the WPF control graph render is never being processed because of that WndProc override. 可能因为WndProc覆盖而导致WPF控件图呈现的事件永远不会被处理。

Since you are inter-oping with WinForms, you can force the events to process by performing a call to Application.DoEvents(); 由于您正在使用WinForms进行交互,因此可以通过调用Application.DoEvents();来强制处理事件Application.DoEvents(); somewhere. 某处。 Perhaps after you update the progress bar. 也许在您更新进度条之后。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM