在 WPF/C# 中嵌入 Firefox/Gecko
我想将当前的 Gecko 嵌入到我的 WPF 项目中。 我知道 Winforms-Host 和 Skybound-Gecko-Library 是有可能的。
但我的应用程序没有使用标准的 wpf 主题。这是另一个,控件的滚动条不会被设置样式。此外,这是一个为 Firefox 3 设计的旧库。
哪个是在 WPF 中使用当前 Gecko 的最佳库/策略?
I want to embed the current Gecko in my WPF-Project.
I know there is the possibility with the Winforms-Host and the Skybound-Gecko-Library.
But I do not use the standard wpf-theme for my application. It is another and the scrollbar of the control will not be styled. Furthermore, this is an old library which is designed for Firefox 3.
Which is the best library/strategy to use the current Gecko in WPF?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您应该看看这些选项,它们都使用 Chromium:
付费:(基于 Awesomium)
免费:(基于 Chrome 嵌入式框架)
You should have a look at these options, they all use Chromium:
paid: (Awesomium-based)
free: (Chrome Embedded Framework-based)
您可以使用 WindowsFormsHost,此处教程
https: //nhabuiduc.wordpress.com/2014/09/18/geckofx-net-webbrowser-setup-and-features/
有趣的部分是
You can probably use WindowsFormsHost, tutorial here
https://nhabuiduc.wordpress.com/2014/09/18/geckofx-net-webbrowser-setup-and-features/
the interesting part is
WebKit.Net 是免费的: http://sourceforge.net/projects/webkitdotnet/
他们的 GitHub 页面似乎最近更新:https://github.com/webkitdotnet
WebKit.Net is free: http://sourceforge.net/projects/webkitdotnet/
Their GitHub page seems to have been more recently updated: https://github.com/webkitdotnet
这是我的答案。正如 Roman 所说,Gecko 是基于 Winforms 的,而不是基于 WPF 的,因此必须通过 WindowsFormsHost 合并。
创建 Visual Studio 项目后,通过 NuGet 安装 Gecko 包,使用命令:Install-Package Geckofx45
确保 WindowsFormsIntegration 和 System.Windows.Forms 引用已添加到您的项目中。
在配置管理器中,将配置设置为 32 位,以消除编译器警告。
更新 MainWindow.xaml“Grid”元素以为其指定名称和“Loaded”事件的处理程序
修改 MainWindow.xaml.cs 以合并 Gecko 并使其在加载时导航到页面:
我很难使用 SO 代码编辑器,因此有关更详细的说明和屏幕截图,请参阅此 博客页面。
Here is my answer. As stated by Roman, Gecko is Winforms-based, not WPF-based and so has to be incorporated via the WindowsFormsHost.
After creating the Visual Studio project, install the Gecko package via NuGet, using the command: Install-Package Geckofx45
Make sure the WindowsFormsIntegration and System.Windows.Forms references have been added to your project.
In your Configuration Manager, set your configuration to 32-bit, to get rid of the compiler warnings.
Update MainWindow.xaml 'Grid' element to give it a name and the handler for the 'Loaded' event
Modify MainWindow.xaml.cs to incorporate the Gecko as well as make it navigate to a page on loading:
I struggle using the SO code editor, so for more detailed explanations and screenshots, see this blog page.
这是一个老问题,但我想出了一个伪解决方案,将 GeckoFX 添加为 XAML 标记,例如:
这可以通过简单地将整个内容包装在 UserControl 中来完成,例如:
XAML:
C#:
现在,您可以在 WPF 中用户控件所在的同一项目中使用该标记。
我一直在尝试让它作为库中的控件工作,这样我就可以轻松地将它移植到任何其他项目/解决方案,但它总是给我一个关于 mozglue.dll 丢失的错误。我怀疑这是由于 Xpcom.Initialize("Firefox") 但我需要进一步调查。
This is an old question, but I came up with a pseudo-solution to add GeckoFX as a XAML tag such as:
This can be accomplished by simply wrapping the whole thing in a UserControl such as:
XAML:
C#:
Now, you can use the tag in WPF, in the same project where the UserControl exists.
I have been trying to get this to work as a Control in a library, so I can easily port it to any other project/solution, but it keeps giving me an error about mozglue.dll missing. I suspect this is due to the Xpcom.Initialize("Firefox") but I need to investigate further.