microsoft / WindowsAppSDK

The Windows App SDK empowers all Windows desktop apps with modern Windows UI, APIs, and platform features, including back-compat support, shipped via NuGet.
https://docs.microsoft.com/windows/apps/windows-app-sdk/
MIT License
3.79k stars 319 forks source link

Changing Mica backdrop in ActualThemeChanged event causes backdrop to render wrong #3230

Open dotMorten opened 1 year ago

dotMorten commented 1 year ago

Describe the bug

I want to change my tint opacity of mica when in dark mode. However when I switch darkmode, setting the tint opacity in the ActualThemeChanged event causes the entire backdrop to render completely wrong.

I also notice that if I delay setting the TintOpacity override, or I don't override it at all, things render just fine.

Steps to reproduce the bug

  1. Unzip the repro project: MicaBugRepro.zip
  2. Launch app and use the dropdown to switch to dark-mode. Notice most text is getting unreadable.
  3. Switch back to light mode, and flip one of the two switches.
  4. Switch to dark mode again, and notice there is no issue.

Expected behavior

Dark mode renders correctly, regardless of if/when TintOpacity is applied.

Screenshots

https://user-images.githubusercontent.com/1378165/206558721-67555f3f-7894-4541-b0da-71cc4f690023.mp4

NuGet package version

Windows App SDK 1.2.1: 1.2.221116.1

Packaging type

Packaged (MSIX)

Windows version

Windows 11 version 22H2 (22621, 2022 Update)

IDE

Visual Studio 2022

Additional context

Reproduced with 1.1.5, 1.2 preview, and 1.2.221116.1

zhuxb711 commented 1 year ago

if comment this out, then the theme would not be changed as expected

micaController.ResetProperties()
zhuxb711 commented 1 year ago

Inclusion:

The code would not works

BackdropConfiguration.Theme = SystemBackdropTheme.Dark //Or SystemBackdropTheme.Light

The code would not works too

BackdropConfiguration.Theme = SystemBackdropTheme.Dark //Or SystemBackdropTheme.Light
micaController.ResetProperties();
micaController.TintColor = //Your Color
micaController.TintOpacity = //Your TintOpacity 
micaController.LuminosityOpacity = //Your LuminosityOpacity

The code would works as expected

BackdropConfiguration.Theme = SystemBackdropTheme.Dark //Or SystemBackdropTheme.Light
micaController.ResetProperties();

@dotMorten I also seem this issue in DesktopAcrylicController not only in MicaController

zhuxb711 commented 1 year ago

For DesktopAcrylicController, those bugs would found.

Set TintOpacity property only would not takes effect

//Change TintOpacity only would not takes effect
acrylicController.TintOpacity = //Your TintOpacity 

Set TintOpacity and LuminosityOpacity property would takes effect

//Change TintOpacity and LuminosityOpacity would takes effect
acrylicController.TintOpacity = //Your TintOpacity 
acrylicController.LuminosityOpacity = //Your LuminosityOpacity