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.84k stars 320 forks source link

Windows.UI.ViewManagement.UISettings.ColorValueChanged does not trigger in WinUI3 app on Windows 10 #4006

Open HO-COOH opened 11 months ago

HO-COOH commented 11 months ago

Describe the bug

Windows.UI.ViewManagement.UISettings.ColorValueChanged does not trigger when changing dark/light mode in system settings with WinUI3 (packaged) app under windows 10.

UWP app does not have such issue.

This issue ONLY seems to happen on Windows 10. I tried on both 17763 and 19045 and both are having issues (and both are working properly with UWP app, which is kind of funny). On Windows 11 22621, no issues.

Steps to reproduce the bug

  1. Create a new C++ WinUI3 app (packaged)
  2. In MainWindow.xaml.h, add a member
    struct MainWindow : MainWindowT<MainWindow>
    {
    ...
    winrt::Windows::UI::ViewManagement::UISettings settings;
    };
  3. In MainWIndow.xaml.cpp
    MainWindow::MainWindow()
    {
        settings.ColorValuesChanged([](auto...)
            {
                OutputDebugString(L"Triggered");
            });
    }
  4. Put a breakpoint on the OutputDebugString line, build and run. Toggle dark/light mode in system settings, the breakpoint is NOT hit.

Expected behavior

No response

Screenshots

WinUI3 (left) <--------------------> UWP (right)

https://github.com/microsoft/WindowsAppSDK/assets/42881734/2589383b-fa92-44ca-a608-3ed7d9fec6db

NuGet package version

Windows App SDK 1.4.3: 1.4.231115000

Packaging type

Packaged (MSIX)

Windows version

Windows 10 version 22H2 (19045, 2022 Update), Windows 10 version 1809 (17763, October 2018 Update)

IDE

Visual Studio 2022

Additional context

No response

DarranRowe commented 11 months ago

I think the issue with ColorValueChanged is that there is documentation stating that it isn't supported. It could be that it wasn't working in Windows 10, but has since been made to work in 11.

HO-COOH commented 11 months ago

I think the issue with ColorValueChanged is that there is documentation stating that it isn't supported. It could be that it wasn't working in Windows 10, but has since been made to work in 11.

I think that's a lie. It works even with a WPF app. image

DarranRowe commented 11 months ago

First, remember that "not supported" is not the same as "doesn't work". It normally means that Microsoft doesn't intend for it to work, but if it works then it is good for you. However, if it doesn't work then they will not support you.

Secondly, is the WPF application packaged?

HO-COOH commented 11 months ago

First, remember that "not supported" is not the same as "doesn't work". It normally means that Microsoft doesn't intend for it to work, but if it works then it is good for you. However, if it doesn't work then they will not support you.

Secondly, is the WPF application packaged?

I use whatever project template visual studio comes with, so the WPF application is not packaged. At this point, I think Microsoft should just update the documentation, what works under which framework, packaged/unpackaged, and what was quitely made to work with Windows 11.