Search code examples
wpfcefsharp

CefSharp WPF turn off transparent background


I am using cefsharp version 79.1.360 for WPF. When ever I create an instance of ChromiumWebBrowser it has a transparent background. How do I turn this off?

private void Button_Click(object sender, RoutedEventArgs e)
{
                    ChromiumWebBrowser cwb = new ChromiumWebBrowser();
                    cwb.IsBrowserInitializedChanged += Cwb_IsBrowserInitializedChanged;
}


 private void Cwb_IsBrowserInitializedChanged(object sender, DependencyPropertyChangedEventArgs e)
{
            ChromiumWebBrowser cwb = (ChromiumWebBrowser)sender;
            cwb.Load("url");
}

Solution

  • ChromiumWebBrowser's default control template doesn't have any way to set a background color. In my apps, I just put a Border behind the control. Simple.

    Otherise, you can override the default style/control template and implement your own.