Hosting your Blazor application in the WinUI WebView2
We’re on the home stretch. We created a Blazor Wasm application, pushed the source code to GitHub, and Azure configured GitHub Actions to publish the application to Azure Static Web Apps with every commit. The last step is to create a simple WinUI 3 project and add a WebView2
control to MainWindow:
- You can start by either creating a new Blank App, Packaged (WinUI in Desktop) named
BlazorTasksHost
in Visual Studio or opening the starter project from GitHub: https://github.com/PacktPublishing/-Learn-WinUI-3/tree/master/Chapter12/Start/BlazorTasksHost. - Open
MainWindow.xaml
and update the window to hostGrid
that contains theWebView2
control. Set theSource
property to the URL of yourBlazorTasksWasm
site:<Grid> <WebView2 Source="https://you-custom-url- 0af06780d.azurestaticapps.net/"/> </Grid>
- Remove the unused button click...