According to the document, it is recommended to use Environment.SetEnvironmentVariable to set the transparency.
Setting DefaultBackgroundColor
On WinUI 2, the DefaultBackgroundColor property is not exposed
directly. You can set the default background color by setting an
environment variable, as follows:
On WinUI 2, transparency is achieved by setting the color to 00FFFFFF.
This environment variable must be set prior to CoreWebView2 creation,
which occurs when the WebView2.Source property is initially set or the
WebView2.EnsureCoreWebView2Async method is initially called.
According to the document, it is recommended to use
Environment.SetEnvironmentVariableto set the transparency.