Add WebView2
Add WebView2 only when the product needs embedded web content.
Add The Control
<Grid>
<WebView2 x:Name="DocsView" />
</Grid>
Initialize and apply navigation policy:
await DocsView.EnsureCoreWebView2Async();
DocsView.CoreWebView2.NavigationStarting += (_, args) =>
{
var allowed = args.Uri.StartsWith("https://docs.example.com/", StringComparison.OrdinalIgnoreCase);
args.Cancel = !allowed;
};
DocsView.Source = new Uri("https://docs.example.com/");
Choose Runtime
| Choice | Default? | Notes |
|---|---|---|
| Evergreen | Yes | Best security/update path for most apps |
| Fixed Version | No | Use for strict compatibility/offline requirements and update it deliberately |
Test
- Native shell still launches without elevation.
- Navigation policy blocks unexpected origins.
- Web content can be smoke-tested with Playwright if complex.
- Runtime availability is tested on a clean machine or documented as installer responsibility.