简体   繁体   English

什么是WPF WebBrowser控件的一个很好的替代品?

[英]What is a good alternative to the WPF WebBrowser Control?

I have an MDI WPF app that I need to add web content to. 我有一个MDI WPF应用程序,我需要添加Web内容。 At first, great it looks like I have 2 options built into the framework the Frame control and the WebBrowser control. 起初,看起来我有两个选项内置到Frame控件和WebBrowser控件的框架中。 Given that this is an MDI app it doesn't take long to discover that neither of these will work. 鉴于这是一个MDI应用程序,它不需要很长时间才能发现这些都不会起作用。

The WPF WebBrowser control wraps up the IE WebBrowser ActiveX Control which uses the Win32 graphics pipeline. WPF WebBrowser控件包装使用Win32图形管道的IE WebBrowser ActiveX控件 The " Airspace " issue pretty much sums this up as "Sorry, the layouts will not play nice together". 空域 ”问题几乎总结为“对不起,布局不会很好地结合在一起”。

Yes, I have thought about taking snapshots of the web content rendering these and mapping the mouse and keyboard events back to the browser control, but I can't afford the performance penalty and I really don't have time to write and thoroughly test it. 是的,我已经考虑过拍摄这些内容的快照,并将鼠标和键盘事件映射回浏览器控件,但是我承担不起性能损失,我真的没有时间编写并彻底测试它。

I have looked for third party controls, but so far I have only found Chris Cavanagh's WPF Chromium Web Browser control. 我已经找了第三方控件,但到目前为止我只找到了Chris Cavanagh的 WPF Chromium Web Browser控件。 Which wraps up Awesomium 1.5 . 其中包含了Awesomium 1.5 Together these are very cool, they play nice with the WPF layouts. 这些非常酷,它们与WPF布局配合得很好。 But they do not meet my performance requirements. 但它们不符合我的性能要求。 They are VERY HEAVY on memory consumption and not to friendly with CPU usage either. 它们在内存消耗方面非常重,而且对CPU使用率也不友好。 Not to mention still quite buggy. 更不用说还有很多车。 I'll elaborate if you are interested. 如果你有兴趣,我会详细说明。

So, do any of you know of a stable performant WPF web browser control? 那么,你们中任何人都知道一个稳定的高性能WPF Web浏览器控件吗?

Thanks. 谢谢。

I don't think there are many fully-managed web controls. 我认为没有很多完全托管的Web控件。 There's an unusual one at http://www.modeltext.com/html/ (I'm its author). http://www.modeltext.com/html/ (我是它的作者)有一个不寻常的。

This a Windows Forms control, not WPF. 这是一个Windows窗体控件,而不是WPF。 The Windows Forms – WPF Interoperability FAQ suggests that's not a problem; Windows窗体 - WPF互操作性常见问题解答表明这不是问题; but I don't know whether the "airspace problem" precludes using a Windows Forms control. 但我不知道“空域问题”是否排除了使用Windows窗体控件。

On the plus side: 从积极的一面:

  • Fully managed 完全管理
  • Performant: low CPU at least (I don't know what your memory requirements are) 性能:至少低CPU(我不知道你的内存需求是多少)
  • Can have more than one instance of it in an application 在应用程序中可以有多个实例

On the minus side: 在负面:

  • Only a subset of the functionality that would be supported by a mainstream browser (so, it depends what you want it for) 只有主流浏览器支持的功能的一部分(因此,它取决于您想要的功能)
  • Beta quality Beta质量

Edit: 编辑:

Looks like nice work. 看起来很不错的工作。

Thank you. 谢谢。

For this application I need a fully functional browser (I must support javascript). 对于这个应用程序,我需要一个功能齐全的浏览器(我必须支持javascript)。

In that case, this wouldn't work for you: this control exposes .NET (not javascript) DOM APIs; 在这种情况下,这对你不起作用:这个控件公开.NET(而不是javascript)DOM API; so, applications can implement and install DOM event handlers, which are written in C# instead of in javascript. 因此,应用程序可以实现和安装DOM事件处理程序,这些处理程序是用C#而不是javascript编写的。

And yes, hosting the control in a WPF app will work fine until you need to layer your objects. 是的,在WPF应用程序中托管控件将正常工作,直到您需要对对象进行分层。 All winforms controls will suffer from this problem due to the rendering pipelines. 由于渲染管道,所有winforms控件都会遇到此问题。 See the link above. 请参阅上面的链接。 Have you considered a native WPF port? 您是否考虑过本地WPF端口?

A WPF port might be possible, because it renders onto/via an abstract device-context-like interface, of which I have two complete/distinct implementations so far: WPF端口可能是可能的,因为它渲染到/通过类似于抽象设备上下文的接口,到目前为止我有两个完整/不同的实现:

  • One uses System.Windows.Forms and System.Drawing 一个使用System.Windows.FormsSystem.Drawing
  • The other is my automated test framework, which implements the 'humble dialog' pattern for GUI regression testing 另一个是我的自动化测试框架,它实现了GUI回归测试的“简单对话”模式

Theoretically perhaps I could implement a third, for WPF, using System.Windows.Controls and System.Windows.Media . 从理论上讲,也许我可以使用System.Windows.ControlsSystem.Windows.Media为WPF实现第三个。

Kind of random but you might find this interesting: http://blog.spencen.com/2008/01/19/html-to-flowdocument-converter.aspx 有点随机,但你可能会觉得这很有趣: http//blog.spencen.com/2008/01/19/html-to-flowdocument-converter.aspx

Thank you for that: I do find that interesting. 谢谢你:我觉得很有意思。 The WPF RichTextBox provides a lot of functionality for editing. WPF RichTextBox提供了许多编辑功能。

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

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