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 configured GitHub Actions to publish the application to Azure Static Web Apps with every commit. The last step is to create a simple WinUI project and add a WebView2
control to the MainPage:
- You can start by either creating a new Blank App (WinUI in UWP) named BlazorTasksHost in Visual Studio or opening the starter project from GitHub: https://github.com/PacktPublishing/-Learn-WinUI-3.0/tree/master/Chapter12/Start/BlazorTasksHost.
- Open MainPage.xaml and update the page to contain a
Grid
that contains theWebView2
control. Set theSource
property to the URL of your BlazorTasks site:<Grid> <WebView2 Source="https://gray-plant- 0af06960f.azurestaticapps.net/"/> </Grid>
- Remove the unused button click event handler in MainPage...