diff --git a/MainPage.xaml b/MainPage.xaml index 410813e..b00d9fa 100644 --- a/MainPage.xaml +++ b/MainPage.xaml @@ -4,7 +4,8 @@ xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:MauiBlazorUIBestPractices" - BackgroundColor="#512bdf"> + BackgroundColor="#512bdf" + Loaded="ContentPage_Loaded"> diff --git a/MainPage.xaml.cs b/MainPage.xaml.cs index bf33dd2..8d8f9b0 100644 --- a/MainPage.xaml.cs +++ b/MainPage.xaml.cs @@ -7,6 +7,7 @@ public partial class MainPage : ContentPage public MainPage() { InitializeComponent(); + Loaded += ContentPage_Loaded; BlazorWebViewHandler.BlazorWebViewMapper.AppendToMapping("CustomBlazorWebViewMapper", (handler, view) => { @@ -28,4 +29,16 @@ public MainPage() #endif }); } + + private async void ContentPage_Loaded(object sender, EventArgs e) + { +#if WINDOWS && RELEASE + var webView2 = (blazorWebView.Handler.PlatformView as Microsoft.UI.Xaml.Controls.WebView2); + await webView2.EnsureCoreWebView2Async(); + + var settings = webView2.CoreWebView2.Settings; + settings.AreBrowserAcceleratorKeysEnabled = false; + settings.IsZoomControlEnabled = false; +#endif + } } \ No newline at end of file