Skip to content

WebView2 Configuration

mattkol edited this page Jul 13, 2021 · 1 revision

WebView2CreationOptions is class that has collection of commonly configurable WebView2 properties. Most EdgeSharp development may not need to make any changes, but advanced users may have need to make changes here and there. Part or entire WebView2CreationOptions can also be overriden in:

The default values will be used.

using EdgeSharp;
using EdgeSharp.Core.Configuration;
using EdgeSharp.Core.Defaults;
using System;

namespace MyEdgeSharpApp
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            // create a configuration with preset defaults
            var config = new Configuration();

            // your configuration
            config.StartUrl = "https://developer.microsoft.com/en-us/microsoft-edge/webview2/";
            config.WindowOptions.Title = "My Awesome EdgeSharp App!";

            config.WebView2CreationOptions.AdditionalBrowserArguments = "disable-web-security";
            config.WebView2CreationOptions.IsStatusBarEnabled = false;
            //..

            AppBuilder
            .Create()
            .UseConfig<IConfiguration>(config)
            .UseApp<SampleEdgeSharpApp>()
            .Build()
            .Run(args);
        }
    }
}