我试图在 Windows 窗体中的 webview2 控件中托管 blazor,但是我设计的布局没有加载,因此页面加载不正确,webview2 中有一个 LayoutEngine 属性,我不知道如何设置:
BlazorWebView blazorWeather = new BlazorWebView()
{
Dock = DockStyle.Fill,
HostPage = "wwwroot/index.html",
Services = serviceProvider,
LayoutEngine =
};
这是解决方案吗?我应该为此设置什么值?
编辑:
这是将 webviews 添加到 Form1 的代码,当我添加布局仅布局显示时,当我添加组件时,它显示:
using (ServiceProvider serviceProvider = services.BuildServiceProvider())
{
BlazorWebView blazorLayout = new BlazorWebView()
{
Dock = DockStyle.Fill,
HostPage = "wwwroot/index.html",
Services = serviceProvider,
};
blazorLayout.RootComponents.Add<MainLayout>("#app");
BlazorWebView blazorComponent = new BlazorWebView()
{
Dock = DockStyle.Fill,
HostPage = "wwwroot/index.html",
Services = serviceProvider
};
blazorComponent.RootComponents.Add<CoronaVirus>("#app");
var form1 = new Form1(); // serviceProvider.GetRequiredService<Form1>();
form1.Controls.Add(blazorLayout);
form1.Controls.Add(blazorComponent);
Application.Run(form1);
}