且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将弹出窗口放在wpf应用程序中的Web浏览器控件上

更新时间:2022-11-01 21:00:28

WebBrowser 控件只是一个ActiveX控件的薄包装器。因此,它在WPF应用程序中遇到空域问题,并且没有简单的方法来解决这个问题。

减少WPF应用程序中的空域问题 - 演示源 - 站点主页 - MSDN博客 [ ^ ]



(这将在.NET 4.5中得到修复,但最终会在发布之前将其删除。)



此外,除非您在运行应用程序的每台计算机上调整注册表,否则控件是陷入IE7模式 [ ^ ]。这意味着您不能在您显示的页面中使用任何现代功能,有些网站可能根本无法使用。



解决方案是使用正确的WPF控件没有这些问题。你***的选择可能是 CEFSharp [ ^ ],它使用与Google Chrome相同的渲染引擎。甚至还有 WPF快速入门指南 [ ^ ]这里是CodeProject。
The WebBrowser control is just a thin wrapper around an ActiveX control. As such, it suffers from airspace problems in WPF applications, and there's no easy way to resolve that.
Mitigating Airspace Issues In WPF Applications - Presentation Source - Site Home - MSDN Blogs[^]

(This was going to be fixed in .NET 4.5, but they ended up dropping it before release.)

Also, unless you tweak the registry on every computer that runs your application, the control is stuck in IE7 mode[^]. That means you can't use any modern features in the pages you display, and some sites might not work at all.

The solution is to use a proper WPF control which doesn't have these problems. Your best bet is probably CEFSharp[^], which uses the same rendering engine as Google Chrome. There's even a WPF Quick Start guide[^] here on CodeProject.


我们没有任何与之相关的示例项目。我们可以使用Popup Expander吗?
Don't we have any sample project relates to the same. Can we do the same using Popup Expander ?