简体   繁体   English

WPF和WinForms WebBrowser控件之间存在哪些功能差异?

[英]What functional differences exist between WPF and WinForms WebBrowser control?

WPF WebBrowser control looks great but knowledge accumlated over time about WinForms WebBrowser is substantial and it's hard to ignore work like csExWB. WPF WebBrowser控件看起来很棒,但随着时间的推移,关于WinForms WebBrowser的知识很多,而且很难忽略像csExWB这样的工作。 It would be nice to know what functional shortcomings or advantages exists in .NET 3.5's WPF WebBrowser control over WinForms WebBrowser control. 很高兴知道.NET 3.5的WPF WebBrowser控件在WinForms WebBrowser控件中存在哪些功能缺陷或优点。 In particular, is it possible to build csExWB-like functionality on top of WPF WebBrowser? 特别是,是否可以在WPF WebBrowser之上构建类似csExWB的功能?

From one full day of frustration with wpf's component, here's what I discovered. 从wpf组件的一整天挫败感来看,这就是我发现的。 Apparently, winforms webbrowser exposes much more methods and properties. 显然,winforms webbrowser暴露了更多的方法和属性。 For instance, there's no IsWebBrowserContextMenuEnabled , ActiveXInstance , etc. in wpf webbrowser. 例如,wpf webbrowser中没有IsWebBrowserContextMenuEnabledActiveXInstance等。

Also, the document property of each contains different types of objects. 此外,每个document属性包含不同类型的对象。 Winform contains a document of type System.Windows.Forms.HtmlDocument with a few interesting methods and properties like PointToClient and GetElementFromPoint . Winform包含System.Windows.Forms.HtmlDocument类型的文档,其中包含一些有趣的方法和属性,如PointToClientGetElementFromPoint Wpf webbrowser document is an Object type document that can be cast to mshtml.HtmlDocument , which only provides the same methods and properties available from a standard html + javascript document. Wpf webbrowser文档是一个Object类型文档,可以转换为mshtml.HtmlDocument ,它只提供标准html + javascript文档中可用的相同方法和属性。 Not very exciting. 不是很令人兴奋。 I don't know if it can be cast to something else (useful that is) since there's no real documentation about it. 我不知道它是否可以被转换为其他东西(有用),因为没有关于它的真实文档。

The only disadvantage I could notice about winforms webbrowser is that the buttons and scrollbars inside the component don't have the same appearance as the wpf native controls. 我注意到winforms webbrowser的唯一缺点是组件内的按钮和滚动条与wpf本机控件的外观不同。

I must admit I don't know the differences, but if you hit problems you could perhaps use WindowsFormsHost to host the winform version in WPF, like so ? 我必须承认我不知道这些差异,但如果遇到问题,你可以使用WindowsFormsHost在WPF中托管winform版本, 就像这样 Ultimately, both is a wrapper around shdocvw, so principles like "pure WPF" don't really apply. 最终,两者都是shdocvw的包装,因此像“纯WPF”这样的原则并不真正适用。

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

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