[英]How can I use the Microsoft Edge WebView2 control in C# windows application
如何使用 Visual Studio 在 C# windows 应用程序中使用 Microsoft Edge WebView2 控件?
Now in 2020 WebView2 supports both WPF and WinForms so you can try to use it in your application.现在在 2020 年,WebView2 同时支持 WPF 和 WinForms,因此您可以尝试在您的应用程序中使用它。
https://docs.microsoft.com/en-us/microsoft-edge/webview2/ https://docs.microsoft.com/en-us/microsoft-edge/webview2/
https://docs.microsoft.com/en-us/microsoft-edge/webview2/gettingstarted/wpf https://docs.microsoft.com/en-us/microsoft-edge/webview2/gettingstarted/wpf
Basically you need to add Nuget package Microsoft.Web.WebView2 and then use WebView2 control.基本上你需要添加 Nuget 包 Microsoft.Web.WebView2 然后使用 WebView2 控件。
The Microsoft Edge WebView2 (powered by Microsoft Edge (Chromium) as the rendering engine) is available on the following programming environments: Win32 C/C++ (GA), .NET Framework 4.6.2 or later, .NET Core 3.1 or later and .NET 5. Microsoft Edge WebView2 (由 Microsoft Edge (Chromium) 作为渲染引擎提供支持)可用于以下编程环境:Win32 C/C++ (GA)、.NET Framework 4.6.2 或更高版本、.NET Core 3.1 或更高版本以及 .网络 5.
Get started with WebView2开始使用 WebView2
Install prerequisites on your machine:在您的机器上安装先决条件:
Create a Windows Forms Application.创建 Windows 窗体应用程序。
Install WebView2 NuGet package in your project.在您的项目中安装 WebView2 NuGet 包。
Drop an instance of the WebView2 from toolbox on your form.从表单上的工具箱中删除 WebView2 的实例。
Set the Source property to a valid URL like: https://example.com and run the application.将 Source 属性设置为有效的 URL,例如: https : //example.com并运行应用程序。
More information更多信息
You cannot currently do it without some hacks as it is missing the interfaces.您目前无法在没有一些黑客的情况下做到这一点,因为它缺少接口。 It only support C++ win32 API for the time being.暂时只支持C++ win32 API。 Please see this post for more information https://github.com/MicrosoftEdge/WebViewFeedback/issues/46有关详细信息,请参阅此帖子https://github.com/MicrosoftEdge/WebViewFeedback/issues/46
I don't recommend that you use webview2 at present.我目前不建议您使用 webview2。 This project is now seriously lacking in perfection.这个项目现在严重缺乏完善。 It used to be able to directly call the kernel of the local edge (no beta version), but now it is actually necessary to install the runtime in advance.以前可以直接调用local edge的kernel(没有beta版),但是现在其实需要提前安装runtime了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.