-
Notifications
You must be signed in to change notification settings - Fork 2
/
MainPage.xaml.cs
48 lines (39 loc) · 1.43 KB
/
MainPage.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using Microsoft.AspNetCore.Components.WebView.Maui;
namespace MauiBlazorUIBestPractices;
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
Loaded += ContentPage_Loaded;
BlazorWebViewHandler.BlazorWebViewMapper.AppendToMapping("CustomBlazorWebViewMapper", (handler, view) =>
{
#if WINDOWS
//Workaround for WinUI splash screen
if (AppInfo.Current.RequestedTheme == AppTheme.Dark)
{
handler.PlatformView.DefaultBackgroundColor = Microsoft.UI.Colors.Black;
}
#endif
#if IOS || MACCATALYST
handler.PlatformView.ScrollView.Bounces = false;
handler.PlatformView.BackgroundColor = UIKit.UIColor.Clear;
handler.PlatformView.Opaque = false;
#endif
#if ANDROID
handler.PlatformView.SetBackgroundColor(Android.Graphics.Color.Transparent);
handler.PlatformView.OverScrollMode = Android.Views.OverScrollMode.Never;
#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
}
}