Min
Min

Reputation: 105

Disable Devtools in Microsoft.Web.WebView2.Wpf component

I want to disable devtools from Webview2 component in wpf application .net5. Please help me how to do it?

Upvotes: 7

Views: 5138

Answers (2)

Amir Touitou
Amir Touitou

Reputation: 3451

WebView2.CoreWebView2InitializationCompleted += (sender, args) =>
{
    if (args.IsSuccess)
    {
        var vw2 = (WebView2)sender;
        vw2!.CoreWebView2.Settings.AreDevToolsEnabled = false;
    }
};

Upvotes: 3

Poul Bak
Poul Bak

Reputation: 10930

After the WebView2 has been initialized.

Do:

webView21.CoreWebView2.Settings.AreDevToolsEnabled = false;

where 'webView21' is the name of the WebView2 control.

You can see all settings here: CoreWebView2Settings Class Definition

Upvotes: 13

Related Questions