dotMorten / WinUIEx

WinUI Extensions
https://dotmorten.github.io/WinUIEx
MIT License
582 stars 37 forks source link

Bug: `DarkTintOpacity` breaks mica backdrop on dark mode #91

Closed yaira2 closed 1 year ago

yaira2 commented 1 year ago

Description

Modifying the DarkTintOpacity causes mica to be applied incorrectly on dark mode.

Steps to repro

  1. Create a MicaSystemBackdrop in xaml and change the DarkTintOpacity value. This issue is only present when you set a custom DarkTintOpacity.
    <winuiex:WindowEx.Backdrop>
    <winuiex:MicaSystemBackdrop DarkTintOpacity="0.8"/>
    </winuiex:WindowEx.Backdrop>

Screenshot

image

Version

This issue was introduced in v2.0

dotMorten commented 1 year ago

Something SUPER funky is going on here. If I step through this method: https://github.com/dotMorten/WinUIEx/blob/ceacf8752b8645c70fdadfe66fdd6c35240a0c72/src/WinUIEx/SystemBackdrop.cs#L374 it's not an issue. As I'm stepping through it, I notice the default Mica values are changing mid-debugging. If I delay the call of this method a few 100 ms, the issue goes away too (but that is error prone and also looks terrible).

It's called from the ActualThemeChanged event: https://github.com/dotMorten/WinUIEx/blob/ceacf8752b8645c70fdadfe66fdd6c35240a0c72/src/WinUIEx/WindowManager.Backdrop.cs#L87

It's like WinAppSDK doesn't like some properties to get changed right after a theme change, but considering you'd likely want different backdrop settings for light and dark mode, this is the time to do it.

@ChewWorker @codendone @BenJKuhn Any thoughts on this? Are we not supposed to update backdrop values in the theme changed event?

dotMorten commented 1 year ago

WinAppSDK bug. Logged: https://github.com/microsoft/WindowsAppSDK/issues/3230

dotMorten commented 1 year ago

Closing now that backdrop APIs are in Windows App SDK and deprecated in WinUIEx

yaira2 commented 1 year ago

@dotMorten thank you for your work on this issue!