Hello,
You can disable right-click context menu by coreWebView2.Settings.AreDefaultContextMenusEnabled = false;
and disable the swipe navigation by coreWebView2.Settings.IsSwipeNavigationEnabled = false;
Firstly, please add x:Name for your webview. Then you can get the webview object in the background code and implement the Navigation event. Please use Conditional compilation to wrap this event as well.
#if WINDOWS
Mywebview.Navigating += Mywebview_Navigating;
#endif
Then, you can disable the right-click context menu and the swipe navigation like following code.
private void Mywebview_Navigating(object? sender, WebNavigatingEventArgs e)
{
#if WINDOWS
WebView webview = (WebView)sender;
Microsoft.Web.WebView2.Core.CoreWebView2 coreWebView2 = (webview.Handler.PlatformView as Microsoft.UI.Xaml.Controls.WebView2).CoreWebView2;
coreWebView2.Settings.IsSwipeNavigationEnabled = false;
coreWebView2.Settings.AreDefaultContextMenusEnabled = false;
coreWebView2.Settings.AreBrowserAcceleratorKeysEnabled = false;
webview.Navigating -= Mywebview_Navigating;
#endif
}
Best Regards, Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.