【问题标题】:WPF Web browser alternativeWPF Web 浏览器替代方案
【发布时间】:2016-04-25 11:46:17
【问题描述】:

我有一个 WPF 应用程序,它使用 webBrowser 控件并且在内部使用 IE7,当我尝试添加任何 javascript 库时会变得很痛苦,因为 IE7 不支持新功能。

我尝试使用

更改浏览器呈现模式
<meta http-equiv="X-UA-Compatible" content="IE=11" />

但它不仅破坏了设计,而且在 IE11 中与在 Windows 应用程序中的 WPF WebBrowser 控件中看起来不同。

我无法使用updating registry as in MSDN article,因为许多用户没有更新注册表的权限,我无法联系所有用户来修复它。

我试图找到任何替代方法来替换内置的WebBrowser 控件,我找到了Awesomium、CEF 和CEFSharp,但它们不允许使用IE,但坚持使用Chromium。并非我的所有用户都有Chromium,但IE11 在他们的所有计算机中都很常见。

那么,真正的问题是,是否有任何浏览器控件可以替换现有的WPF WebBrowser 控件并使用更高版本的IE?或者是否有任何其他解决方案可以使现有的WebBrowser 控制使用IE 和我选择的版本?可能是IE9+

【问题讨论】:

  • 我认为 CEFSharp 捆绑了所有必要的东西 - 我不认为它依赖于目标 PC 上安装的 Chrome/Chromium?
  • CefSharp 不需要安装Chrome。您不能直接使用CEF,因为它只提供C/C++ API,您需要查看CefSharp、CefGlue 或ChromiumFx 作为.Net wrappers 的三个CEF。 CefSharp 需要 VC++,您可以将其打包到您的应用中,请参阅 FAQ

标签: c# .net wpf chromium-embedded


【解决方案1】:

尝试使用 WindowsFormsHost

<Window x:Class="WpfTutorialSamples.Misc_controls.WindowsFormsHostSample"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
        Title="WindowsFormsHostSample" Height="350" Width="450">
    <Grid>
        <WindowsFormsHost Name="wfhSample">
            <WindowsFormsHost.Child>
                <wf:WebBrowser DocumentTitleChanged="wbWinForms_DocumentTitleChanged" />
            </WindowsFormsHost.Child>
        </WindowsFormsHost>
    </Grid>
</Window>

从这个例子...

http://www.wpf-tutorial.com/misc-controls/the-windowsformshost-control/

【讨论】:

  • 您会遇到同样的底层 WebBrowser 技术/问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-05-20
  • 2015-05-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-12-09
  • 2012-05-20
相关资源
最近更新 更多