Wpf.Extensions.Hosting
Wpf.Extensions.Hosting copied to clipboard
Can not work on Blazor Hybrid Wpf.
Environment
dotnet --version
- 8.0.205
dotnet --list-runtimes | where { $_.Contains("8.") }
- Microsoft.AspNetCore.App 8.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
- Microsoft.NETCore.App 8.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
- Microsoft.WindowsDesktop.App 8.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Steps to reproduce
- Create a Blazor Hybird Wpf project based on the following this site.
- Apply Wpf.Extensions.Hosting with reference to the following site.
Sample code
This is sample code I made.
Expected
This screen displayed.
Actural
This screen displayed.
Additional context
I know the following this:
- If the following code is enabled in Program.cs, it will not work.
builder.Services.AddWpfBlazorWebView();
- It works if the following code is enabled in MainWindow.xaml.cs.
var serviceCollection = new ServiceCollection();
serviceCollection.AddWpfBlazorWebView();
Resources.Add(“services”, serviceCollection.BuildServiceProvider());
@neko3cs Change the MainWindow class in MainWindow.xaml.cs to the following code to make it work properly.
public partial class MainWindow : Window
{
public MainWindow(IServiceProvider serviceProvider)
{
InitializeComponent();
Resources.Add("services", serviceProvider);
}
}