Skip to content

ThemeListener.ThemeChanged does not work in WinUI 3 #555

Open
@yoshiask

Description

@yoshiask

Describe the bug

ThemeListener seems to do nothing in WinAppSDK apps. A comment in a related issue points out that the events ThemeListener relies on are no longer supported in WinUI 3.

  • Is this bug a regression in the toolkit? If so, what toolkit version did you last see it work:
    7.1.2 for UWP

Steps to Reproduce

  • Can this be reproduced in the Sample App? (Either in a sample as-is or with new XAML pasted in the editor.) If so, please provide custom XAML or steps to reproduce. If not, let us know why it can't be reproduced (e.g. more complex setup, environment, dependencies, etc...)

Steps to reproduce the behavior:

Place the following code anywhere inside a WinAppSDK 1.0.0 C# app:

private void ThemeChanged(ThemeListener sender)
{
    ApplicationTheme theme = sender.CurrentTheme;
    Debug.WriteLine(theme);
}
ThemeListener themeListener = new();
themeListener.ThemeChanged += ThemeChanged;

Observe that the ThemeChanged handler is never fired.

Expected behavior

The ThemeChanged event should fire when the system theme is changed.

Environment

NuGet Package(s): CommunityToolkit.WinUI.UI

Package Version(s): 7.1.2

Windows 10 Build Number:

  • Fall Creators Update (16299)
  • April 2018 Update (17134)
  • October 2018 Update (17763)
  • May 2019 Update (18362)
  • May 2020 Update (19041)
  • Insider Build (22504.1010)

App min and target version:

  • Fall Creators Update (16299)
  • April 2018 Update (17134)
  • October 2018 Update (17763)
  • May 2019 Update (18362)
  • May 2020 Update (19041)
  • Insider Build (22000)

Device form factor:

  • Desktop
  • Xbox
  • Surface Hub
  • IoT

Visual Studio version:

  • 2017 (15.{minor_version})
  • 2019 (16.{minor_version})
  • 2022 (17.0.2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingregressionWhat was working is now broke

    Type

    Projects

    Status

    🏗 In progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions