WebView2.DefaultBackgroundColor cannot be set to a transparent background
See original GitHub issueDescribe the bug
Setting WebView2.DefaultBackgroundColor to transparent results in a Background that seems to be equivalent to the color of ApplicationPageBackgroundThemeBrush (e.g. 32, 32, 32 in Dark theme). That is not what I want. And changing the RequestedTheme at runtime after CoreWebView2 has initialized has no effect on the background color. Moreover, changing the RequestedTheme has no effect at all, the WebView2 control seems to set the background based on the ApplicationTheme which cannot be changed at runtime.
Steps to reproduce the bug
XAML:
<Grid Background="Red">
<WebView2 DefaultBackgroundColor="Transparent" Loading="WebView2loading"></WebView2>
</Grid>
C#:
private async void WebView2loading(FrameworkElement sender, object args)
{
await ((WebView2)sender).EnsureCoreWebView2Async();
}
Expected behavior
The expected behavior is that setting the BackgroundColor to transparent should set the background color to transparent.
Screenshots
The Background should be red in the example.
NuGet package version
WinUI 3 - Windows App SDK 1.0 (If you’re seeing your issue in older previews of WinUI 3, please try this release)
Windows app type
- UWP
- Win32
Device form factor
Desktop
Windows version
Insider Build (xxxxx)
Additional context
Testet on 21H2 (22000.376)
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:8 (1 by maintainers)
Top GitHub Comments
The target version of our UWP App is 19041
Note that there is another issue: https://github.com/MicrosoftEdge/WebView2Feedback/issues/2917
Because of this one we can’t go live for months
The issue still exists in WinUI 3 ver 1.1 C# Desktop