Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Is it possible to modify WebView2 settings in a blazor wpf app?

$
0
0

I have a wpf app with blazor integrated in it. I would like to disable certain features like dev tools and page zooming. To do this, you would generally modify WebView2 settings like so:

var coreWebView2 = webView2Control.CoreWebView2;coreWebView2.Settings.IsZoomControlEnabled = false;coreWebView2.Settings.AreDevToolsEnabled = false;

The problem with the Blazor WebView is that it doesn't directly expose its underlying WebView2 properties to modify - at least that I haven't found. This is how I would expect to modify the WebView2 settings of a Blazor WebView:

private void BlazorWebView_Loaded(object sender, RoutedEventArgs e){    var webView2Control = blazorWebView.WebView;    if (webView2Control?.CoreWebView2 != null)    {         webView2Control.CoreWebView2.Settings.IsZoomControlEnabled = false;         webView2Control.CoreWebView2.Settings.AreDevToolsEnabled = false;    }}

This, however, won't work because WebView doesn't exist under the BlazorWebView.

My question is, is it actually possible to access the BlazorWebView underlying WebView2 settings? If you truly can't, how could you disable dev tools and page zooming in the BlazorWebView?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>