Skip to content

Commit

Permalink
[WinUI] Disable refresh and zooming in Release mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mhrastegari committed Feb 14, 2023
1 parent d8c724d commit ac53079
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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">

<BlazorWebView x:Name="blazorWebView" HostPage="wwwroot/index.html">
<BlazorWebView.RootComponents>
Expand Down
13 changes: 13 additions & 0 deletions MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public partial class MainPage : ContentPage
public MainPage()
{
InitializeComponent();
Loaded += ContentPage_Loaded;

BlazorWebViewHandler.BlazorWebViewMapper.AppendToMapping("CustomBlazorWebViewMapper", (handler, view) =>
{
Expand All @@ -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
}
}

0 comments on commit ac53079

Please sign in to comment.