Skip to content

Conversation

@Nitin-100
Copy link
Contributor

@Nitin-100 Nitin-100 commented Feb 7, 2026

Description

The app's title bar was not updating its colors when switching between dark and light mode in Windows system settings. This PR fixes the issue so the title bar correctly reflects the current system theme.

What

When changing the Windows system theme from dark to light (or vice versa), the app's title bar remained in the old theme colors while the rest of the app updated.

Root Cause

Two issues in NewArch/windows/NewArch/NewArch.cpp:

  1. UISettings object going out of scope — The uiSettings variable used to subscribe to ColorValuesChanged was a local variable inside the try block. Once the block finished executing, the object was destroyed, silently removing the event subscription. The theme change callback would never fire.

  2. Background thread callbackColorValuesChanged fires on a background thread, but updating the title bar requires running on the UI thread.

How

  • Made the UISettings instance static so it persists for the entire lifetime of the application, keeping the ColorValuesChanged event subscription alive.
  • Captured the DispatcherQueue for the UI thread and used TryEnqueue inside the callback to marshal the title bar update back to the UI thread.

Changes

  • NewArch/windows/NewArch/NewArch.cpp — Fixed title bar theme change listener lifetime and thread marshaling.

Screenshot

Fixtheme.mp4

Testing

  1. Build and run the NewArch gallery app on Windows
  2. Open Windows Settings → Personalization → Colors
  3. Switch between Light and Dark mode
  4. Verify the app's title bar updates to match the new system theme
Microsoft Reviewers: Open in CodeFlow

@iamAbhi-916
Copy link
Contributor

/azp run pr

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants