Skip to content

[Windows] Fix runtime theme update for controls and TitleBar#31714

Merged
PureWeen merged 20 commits intodotnet:inflight/currentfrom
Tamilarasan-Paranthaman:fix-30518
Jan 22, 2026
Merged

[Windows] Fix runtime theme update for controls and TitleBar#31714
PureWeen merged 20 commits intodotnet:inflight/currentfrom
Tamilarasan-Paranthaman:fix-30518

Conversation

@Tamilarasan-Paranthaman
Copy link
Member

@Tamilarasan-Paranthaman Tamilarasan-Paranthaman commented Sep 22, 2025

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Root Cause of the Issue:

  • In WinUI, the theme can only be set when the app is started, not while it's running. On the .NET MAUI side, we explicitly update control colors according to the defined styles for the respective theme. As a result, colors were updated correctly for the controls we handled explicitly.

  • However, controls where we did not explicitly set the colors (e.g., DatePicker/TimePicker backgrounds, Checkbox tick marks, and TitleBar colors) were not updated properly when the theme changed.

  • This happens because WinUI default colors are tied to the theme at the time the app is launched. For example, if the app starts in Light theme, the WinUI theme is initialized as Light and its colors are applied for the entire lifecycle. These defaults are not refreshed when the theme changes at runtime.

  • Due to this limitation, theme-related colors (including TitleBar color) were not updated as expected.

Description of Change

  • Implemented a common logic to apply the appropriate theme by setting the RequestedTheme on the root view of the Window. This approach is consistent with what is used in the WinUI Gallery repo.

  • With this change, theme-related colors are correctly refreshed across all child views, resolving both theming inconsistencies and the TitleBar color issue when the app theme is changed.

Reference:

Screenshot

Before Fix After Fix
Before-Fix.mp4
After-Fix.mp4

Issues Fixed

Fixes #12507
Fixes #22058
Fixes #30518 (Windows)
Fixes #30807
Fixes #31819

@dotnet-policy-service dotnet-policy-service bot added community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration labels Sep 22, 2025
@sheiksyedm sheiksyedm added the area-theme Themes, theming label Sep 22, 2025
@Tamilarasan-Paranthaman Tamilarasan-Paranthaman marked this pull request as ready for review September 23, 2025 05:02
Copilot AI review requested due to automatic review settings September 23, 2025 05:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes runtime theme changes for Windows controls and TitleBar by implementing proper theme propagation through WinUI's root view element. The issue occurred because WinUI's default colors are tied to the theme at app launch and don't update when the theme changes at runtime.

  • Implements theme application by setting RequestedTheme on the root view of each window
  • Adds proper TitleBar button color handling for theme changes
  • Creates comprehensive UI tests to validate theme switching behavior

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Core/src/Platform/Windows/MauiWinUIWindow.cs Removes hardcoded theme logic and adds code style improvements
src/Controls/src/Core/Application/Application.cs Adds platform-specific hooks for theme and window lifecycle events
src/Controls/src/Core/Application/Application.Windows.cs Implements Windows-specific theme application logic and TitleBar color management
src/Controls/tests/TestCases.HostApp/Issues/Issue22058.cs Creates test UI page with theme switching button and TimePicker
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue22058.cs Adds automated test to verify theme changes work correctly

@malsabi
Copy link

malsabi commented Sep 25, 2025

Does this work also on Picker control it uses ComboBox for WinUI, I faced issues with the drop-down menu and context-menu's not respecting the theme light / dark mode. Can you please confirm. @Tamilarasan-Paranthaman

@Tamilarasan-Paranthaman
Copy link
Member Author

Does this work also on Picker control it uses ComboBox for WinUI, I faced issues with the drop-down menu and context-menu's not respecting the theme light / dark mode. Can you please confirm. @Tamilarasan-Paranthaman

@malsabi, yes, I have tested this with the Picker control, and it respects Light/Dark theme changes correctly with this fix. I have attached the test code along with videos showing the behavior both with the latest NuGet version and with this fix for your reference. Please let me know if there are any other scenarios you would like me to check, and I will check them on my end and update you.

Tested Code:

<Picker x:Name="picker"
      VerticalOptions="Center"
      Title="Select a monkey">
  <Picker.ItemsSource>
    <x:Array Type="{x:Type x:String}">
      <x:String>Baboon</x:String>
      <x:String>Capuchin Monkey</x:String>
      <x:String>Blue Monkey</x:String>
      <x:String>Squirrel Monkey</x:String>
      <x:String>Golden Lion Tamarin</x:String>
      <x:String>Howler Monkey</x:String>
      <x:String>Japanese Macaque</x:String>
    </x:Array>
  </Picker.ItemsSource>
</Picker>

Screenshot

With latest NuGet With this Fix
Picker-With-Latest-NuGet.mp4
Picker-With-This-Fix.mp4

@PureWeen PureWeen added the p/0 Current heighest priority issues that we are targeting for a release. label Oct 6, 2025
@PureWeen PureWeen added this to the .NET 10.0 GA milestone Oct 6, 2025
@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@Tamilarasan-Paranthaman
Copy link
Member Author

Tamilarasan-Paranthaman commented Oct 9, 2025

@jsuarezruiz, it seems the CI generated images are not rendered properly on Windows. The Title Bar is not visible, and a grey overlay appears in the images.

However, the sample works as expected when run locally. I have attached the CI generated images below for your reference.

I also added a Thread.Sleep after the theme change, maybe that isn’t the proper approach? Should we use Task.Delay instead? I’m not sure why it behaves differently in the CI environment.

I have now replaced Thread.Sleep with Task.Delay. Could you please run the UI tests to regenerate the Windows images?

Debugging in local CI Images (Windows)
App.mp4
VerifyTimePickerTheme VerifyTitleBarBackgroundColorChange

@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Tamilarasan-Paranthaman
Copy link
Member Author

Tamilarasan-Paranthaman commented Oct 13, 2025

@jsuarezruiz, The image is still not generated properly, and this issue occurs only in the CI environment. When I debug the sample locally, it works fine. It also works correctly when I run it from the Test Explorer in Visual Studio. For now, I have added the CI generated image and also set the page’s BackgroundProperty using SetAppThemeColor to see if it helps in the CI environment. Could you please share your insights on this?

@PureWeen
Copy link
Member

/azp run maui-pr-uitests, maui-pr-devicetests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@github-project-automation github-project-automation bot moved this from Ready To Review to Approved in MAUI SDK Ongoing Jan 22, 2026
@PureWeen PureWeen changed the base branch from main to inflight/current January 22, 2026 14:18
@PureWeen PureWeen merged commit 693ed6f into dotnet:inflight/current Jan 22, 2026
18 of 28 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in MAUI SDK Ongoing Jan 22, 2026
github-actions bot pushed a commit that referenced this pull request Jan 23, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Root Cause of the Issue:
- In WinUI, the theme can only be set when the app is started, not while
it's running. On the .NET MAUI side, we explicitly update control colors
according to the defined styles for the respective theme. As a result,
colors were updated correctly for the controls we handled explicitly.

- However, controls where we did not explicitly set the colors (e.g.,
DatePicker/TimePicker backgrounds, Checkbox tick marks, and TitleBar
colors) were not updated properly when the theme changed.

- This happens because WinUI default colors are tied to the theme at the
time the app is launched. For example, if the app starts in Light theme,
the WinUI theme is initialized as Light and its colors are applied for
the entire lifecycle. These defaults are not refreshed when the theme
changes at runtime.

- Due to this limitation, theme-related colors (including TitleBar
color) were not updated as expected.

### Description of Change

- Implemented a common logic to apply the appropriate theme by setting
the RequestedTheme on the root view of the Window. This approach is
consistent with what is used in the WinUI Gallery repo.

- With this change, theme-related colors are correctly refreshed across
all child views, resolving both theming inconsistencies and the TitleBar
color issue when the app theme is changed.

### Reference: 
- The implementation is based on the following references. Additionally,
there is a known issue in WinUI where updating the theme at runtime does
not refresh the TitleBar caption button colors, which requires manual
handling.

- **Updating Root View RequestedTheme:**
https://github.com/microsoft/WinUI-Gallery/blob/96dc185a3a3e488f820d06579d85cb4f480a7089/WinUIGallery/Helpers/ThemeHelper.cs#L62
- **AppWindow TitleBar doesn't update caption button colors correctly
when changed while app is running:**
https://github.com/microsoft/WinUI-Gallery/blob/96dc185a3a3e488f820d06579d85cb4f480a7089/WinUIGallery/Helpers/TitleBarHelper.cs#L22


### Screenshot

| Before Fix | After Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/0db22e18-cbcc-4cdc-857e-c1b093497309">
| <video
src="https://github.com/user-attachments/assets/2e53efce-4122-4179-93aa-c549ded74878">
|




### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #12507
Fixes #22058
Fixes #30518 (Windows)
Fixes #30807
Fixes #31819

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

---------

Co-authored-by: Vignesh-SF3580 <vignesh.nagarajan@syncfusion.com>
PureWeen pushed a commit that referenced this pull request Jan 27, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Root Cause of the Issue:
- In WinUI, the theme can only be set when the app is started, not while
it's running. On the .NET MAUI side, we explicitly update control colors
according to the defined styles for the respective theme. As a result,
colors were updated correctly for the controls we handled explicitly.

- However, controls where we did not explicitly set the colors (e.g.,
DatePicker/TimePicker backgrounds, Checkbox tick marks, and TitleBar
colors) were not updated properly when the theme changed.

- This happens because WinUI default colors are tied to the theme at the
time the app is launched. For example, if the app starts in Light theme,
the WinUI theme is initialized as Light and its colors are applied for
the entire lifecycle. These defaults are not refreshed when the theme
changes at runtime.

- Due to this limitation, theme-related colors (including TitleBar
color) were not updated as expected.

### Description of Change

- Implemented a common logic to apply the appropriate theme by setting
the RequestedTheme on the root view of the Window. This approach is
consistent with what is used in the WinUI Gallery repo.

- With this change, theme-related colors are correctly refreshed across
all child views, resolving both theming inconsistencies and the TitleBar
color issue when the app theme is changed.

### Reference: 
- The implementation is based on the following references. Additionally,
there is a known issue in WinUI where updating the theme at runtime does
not refresh the TitleBar caption button colors, which requires manual
handling.

- **Updating Root View RequestedTheme:**
https://github.com/microsoft/WinUI-Gallery/blob/96dc185a3a3e488f820d06579d85cb4f480a7089/WinUIGallery/Helpers/ThemeHelper.cs#L62
- **AppWindow TitleBar doesn't update caption button colors correctly
when changed while app is running:**
https://github.com/microsoft/WinUI-Gallery/blob/96dc185a3a3e488f820d06579d85cb4f480a7089/WinUIGallery/Helpers/TitleBarHelper.cs#L22


### Screenshot

| Before Fix | After Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/0db22e18-cbcc-4cdc-857e-c1b093497309">
| <video
src="https://github.com/user-attachments/assets/2e53efce-4122-4179-93aa-c549ded74878">
|




### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #12507
Fixes #22058
Fixes #30518 (Windows)
Fixes #30807
Fixes #31819

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

---------

Co-authored-by: Vignesh-SF3580 <vignesh.nagarajan@syncfusion.com>
PureWeen pushed a commit that referenced this pull request Jan 29, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Root Cause of the Issue:
- In WinUI, the theme can only be set when the app is started, not while
it's running. On the .NET MAUI side, we explicitly update control colors
according to the defined styles for the respective theme. As a result,
colors were updated correctly for the controls we handled explicitly.

- However, controls where we did not explicitly set the colors (e.g.,
DatePicker/TimePicker backgrounds, Checkbox tick marks, and TitleBar
colors) were not updated properly when the theme changed.

- This happens because WinUI default colors are tied to the theme at the
time the app is launched. For example, if the app starts in Light theme,
the WinUI theme is initialized as Light and its colors are applied for
the entire lifecycle. These defaults are not refreshed when the theme
changes at runtime.

- Due to this limitation, theme-related colors (including TitleBar
color) were not updated as expected.

### Description of Change

- Implemented a common logic to apply the appropriate theme by setting
the RequestedTheme on the root view of the Window. This approach is
consistent with what is used in the WinUI Gallery repo.

- With this change, theme-related colors are correctly refreshed across
all child views, resolving both theming inconsistencies and the TitleBar
color issue when the app theme is changed.

### Reference: 
- The implementation is based on the following references. Additionally,
there is a known issue in WinUI where updating the theme at runtime does
not refresh the TitleBar caption button colors, which requires manual
handling.

- **Updating Root View RequestedTheme:**
https://github.com/microsoft/WinUI-Gallery/blob/96dc185a3a3e488f820d06579d85cb4f480a7089/WinUIGallery/Helpers/ThemeHelper.cs#L62
- **AppWindow TitleBar doesn't update caption button colors correctly
when changed while app is running:**
https://github.com/microsoft/WinUI-Gallery/blob/96dc185a3a3e488f820d06579d85cb4f480a7089/WinUIGallery/Helpers/TitleBarHelper.cs#L22


### Screenshot

| Before Fix | After Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/0db22e18-cbcc-4cdc-857e-c1b093497309">
| <video
src="https://github.com/user-attachments/assets/2e53efce-4122-4179-93aa-c549ded74878">
|




### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #12507
Fixes #22058
Fixes #30518 (Windows)
Fixes #30807
Fixes #31819

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

---------

Co-authored-by: Vignesh-SF3580 <vignesh.nagarajan@syncfusion.com>
PureWeen pushed a commit that referenced this pull request Feb 2, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Root Cause of the Issue:
- In WinUI, the theme can only be set when the app is started, not while
it's running. On the .NET MAUI side, we explicitly update control colors
according to the defined styles for the respective theme. As a result,
colors were updated correctly for the controls we handled explicitly.

- However, controls where we did not explicitly set the colors (e.g.,
DatePicker/TimePicker backgrounds, Checkbox tick marks, and TitleBar
colors) were not updated properly when the theme changed.

- This happens because WinUI default colors are tied to the theme at the
time the app is launched. For example, if the app starts in Light theme,
the WinUI theme is initialized as Light and its colors are applied for
the entire lifecycle. These defaults are not refreshed when the theme
changes at runtime.

- Due to this limitation, theme-related colors (including TitleBar
color) were not updated as expected.

### Description of Change

- Implemented a common logic to apply the appropriate theme by setting
the RequestedTheme on the root view of the Window. This approach is
consistent with what is used in the WinUI Gallery repo.

- With this change, theme-related colors are correctly refreshed across
all child views, resolving both theming inconsistencies and the TitleBar
color issue when the app theme is changed.

### Reference: 
- The implementation is based on the following references. Additionally,
there is a known issue in WinUI where updating the theme at runtime does
not refresh the TitleBar caption button colors, which requires manual
handling.

- **Updating Root View RequestedTheme:**
https://github.com/microsoft/WinUI-Gallery/blob/96dc185a3a3e488f820d06579d85cb4f480a7089/WinUIGallery/Helpers/ThemeHelper.cs#L62
- **AppWindow TitleBar doesn't update caption button colors correctly
when changed while app is running:**
https://github.com/microsoft/WinUI-Gallery/blob/96dc185a3a3e488f820d06579d85cb4f480a7089/WinUIGallery/Helpers/TitleBarHelper.cs#L22


### Screenshot

| Before Fix | After Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/0db22e18-cbcc-4cdc-857e-c1b093497309">
| <video
src="https://github.com/user-attachments/assets/2e53efce-4122-4179-93aa-c549ded74878">
|




### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #12507
Fixes #22058
Fixes #30518 (Windows)
Fixes #30807
Fixes #31819

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

---------

Co-authored-by: Vignesh-SF3580 <vignesh.nagarajan@syncfusion.com>
github-actions bot pushed a commit that referenced this pull request Feb 4, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Root Cause of the Issue:
- In WinUI, the theme can only be set when the app is started, not while
it's running. On the .NET MAUI side, we explicitly update control colors
according to the defined styles for the respective theme. As a result,
colors were updated correctly for the controls we handled explicitly.

- However, controls where we did not explicitly set the colors (e.g.,
DatePicker/TimePicker backgrounds, Checkbox tick marks, and TitleBar
colors) were not updated properly when the theme changed.

- This happens because WinUI default colors are tied to the theme at the
time the app is launched. For example, if the app starts in Light theme,
the WinUI theme is initialized as Light and its colors are applied for
the entire lifecycle. These defaults are not refreshed when the theme
changes at runtime.

- Due to this limitation, theme-related colors (including TitleBar
color) were not updated as expected.

### Description of Change

- Implemented a common logic to apply the appropriate theme by setting
the RequestedTheme on the root view of the Window. This approach is
consistent with what is used in the WinUI Gallery repo.

- With this change, theme-related colors are correctly refreshed across
all child views, resolving both theming inconsistencies and the TitleBar
color issue when the app theme is changed.

### Reference: 
- The implementation is based on the following references. Additionally,
there is a known issue in WinUI where updating the theme at runtime does
not refresh the TitleBar caption button colors, which requires manual
handling.

- **Updating Root View RequestedTheme:**
https://github.com/microsoft/WinUI-Gallery/blob/96dc185a3a3e488f820d06579d85cb4f480a7089/WinUIGallery/Helpers/ThemeHelper.cs#L62
- **AppWindow TitleBar doesn't update caption button colors correctly
when changed while app is running:**
https://github.com/microsoft/WinUI-Gallery/blob/96dc185a3a3e488f820d06579d85cb4f480a7089/WinUIGallery/Helpers/TitleBarHelper.cs#L22


### Screenshot

| Before Fix | After Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/0db22e18-cbcc-4cdc-857e-c1b093497309">
| <video
src="https://github.com/user-attachments/assets/2e53efce-4122-4179-93aa-c549ded74878">
|




### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #12507
Fixes #22058
Fixes #30518 (Windows)
Fixes #30807
Fixes #31819

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

---------

Co-authored-by: Vignesh-SF3580 <vignesh.nagarajan@syncfusion.com>
github-actions bot pushed a commit that referenced this pull request Feb 8, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Root Cause of the Issue:
- In WinUI, the theme can only be set when the app is started, not while
it's running. On the .NET MAUI side, we explicitly update control colors
according to the defined styles for the respective theme. As a result,
colors were updated correctly for the controls we handled explicitly.

- However, controls where we did not explicitly set the colors (e.g.,
DatePicker/TimePicker backgrounds, Checkbox tick marks, and TitleBar
colors) were not updated properly when the theme changed.

- This happens because WinUI default colors are tied to the theme at the
time the app is launched. For example, if the app starts in Light theme,
the WinUI theme is initialized as Light and its colors are applied for
the entire lifecycle. These defaults are not refreshed when the theme
changes at runtime.

- Due to this limitation, theme-related colors (including TitleBar
color) were not updated as expected.

### Description of Change

- Implemented a common logic to apply the appropriate theme by setting
the RequestedTheme on the root view of the Window. This approach is
consistent with what is used in the WinUI Gallery repo.

- With this change, theme-related colors are correctly refreshed across
all child views, resolving both theming inconsistencies and the TitleBar
color issue when the app theme is changed.

### Reference: 
- The implementation is based on the following references. Additionally,
there is a known issue in WinUI where updating the theme at runtime does
not refresh the TitleBar caption button colors, which requires manual
handling.

- **Updating Root View RequestedTheme:**
https://github.com/microsoft/WinUI-Gallery/blob/96dc185a3a3e488f820d06579d85cb4f480a7089/WinUIGallery/Helpers/ThemeHelper.cs#L62
- **AppWindow TitleBar doesn't update caption button colors correctly
when changed while app is running:**
https://github.com/microsoft/WinUI-Gallery/blob/96dc185a3a3e488f820d06579d85cb4f480a7089/WinUIGallery/Helpers/TitleBarHelper.cs#L22


### Screenshot

| Before Fix | After Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/0db22e18-cbcc-4cdc-857e-c1b093497309">
| <video
src="https://github.com/user-attachments/assets/2e53efce-4122-4179-93aa-c549ded74878">
|




### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #12507
Fixes #22058
Fixes #30518 (Windows)
Fixes #30807
Fixes #31819

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

---------

Co-authored-by: Vignesh-SF3580 <vignesh.nagarajan@syncfusion.com>
PureWeen pushed a commit that referenced this pull request Feb 9, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Root Cause of the Issue:
- In WinUI, the theme can only be set when the app is started, not while
it's running. On the .NET MAUI side, we explicitly update control colors
according to the defined styles for the respective theme. As a result,
colors were updated correctly for the controls we handled explicitly.

- However, controls where we did not explicitly set the colors (e.g.,
DatePicker/TimePicker backgrounds, Checkbox tick marks, and TitleBar
colors) were not updated properly when the theme changed.

- This happens because WinUI default colors are tied to the theme at the
time the app is launched. For example, if the app starts in Light theme,
the WinUI theme is initialized as Light and its colors are applied for
the entire lifecycle. These defaults are not refreshed when the theme
changes at runtime.

- Due to this limitation, theme-related colors (including TitleBar
color) were not updated as expected.

### Description of Change

- Implemented a common logic to apply the appropriate theme by setting
the RequestedTheme on the root view of the Window. This approach is
consistent with what is used in the WinUI Gallery repo.

- With this change, theme-related colors are correctly refreshed across
all child views, resolving both theming inconsistencies and the TitleBar
color issue when the app theme is changed.

### Reference: 
- The implementation is based on the following references. Additionally,
there is a known issue in WinUI where updating the theme at runtime does
not refresh the TitleBar caption button colors, which requires manual
handling.

- **Updating Root View RequestedTheme:**
https://github.com/microsoft/WinUI-Gallery/blob/96dc185a3a3e488f820d06579d85cb4f480a7089/WinUIGallery/Helpers/ThemeHelper.cs#L62
- **AppWindow TitleBar doesn't update caption button colors correctly
when changed while app is running:**
https://github.com/microsoft/WinUI-Gallery/blob/96dc185a3a3e488f820d06579d85cb4f480a7089/WinUIGallery/Helpers/TitleBarHelper.cs#L22


### Screenshot

| Before Fix | After Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/0db22e18-cbcc-4cdc-857e-c1b093497309">
| <video
src="https://github.com/user-attachments/assets/2e53efce-4122-4179-93aa-c549ded74878">
|




### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #12507
Fixes #22058
Fixes #30518 (Windows)
Fixes #30807
Fixes #31819

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

---------

Co-authored-by: Vignesh-SF3580 <vignesh.nagarajan@syncfusion.com>
github-actions bot pushed a commit that referenced this pull request Feb 9, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Root Cause of the Issue:
- In WinUI, the theme can only be set when the app is started, not while
it's running. On the .NET MAUI side, we explicitly update control colors
according to the defined styles for the respective theme. As a result,
colors were updated correctly for the controls we handled explicitly.

- However, controls where we did not explicitly set the colors (e.g.,
DatePicker/TimePicker backgrounds, Checkbox tick marks, and TitleBar
colors) were not updated properly when the theme changed.

- This happens because WinUI default colors are tied to the theme at the
time the app is launched. For example, if the app starts in Light theme,
the WinUI theme is initialized as Light and its colors are applied for
the entire lifecycle. These defaults are not refreshed when the theme
changes at runtime.

- Due to this limitation, theme-related colors (including TitleBar
color) were not updated as expected.

### Description of Change

- Implemented a common logic to apply the appropriate theme by setting
the RequestedTheme on the root view of the Window. This approach is
consistent with what is used in the WinUI Gallery repo.

- With this change, theme-related colors are correctly refreshed across
all child views, resolving both theming inconsistencies and the TitleBar
color issue when the app theme is changed.

### Reference: 
- The implementation is based on the following references. Additionally,
there is a known issue in WinUI where updating the theme at runtime does
not refresh the TitleBar caption button colors, which requires manual
handling.

- **Updating Root View RequestedTheme:**
https://github.com/microsoft/WinUI-Gallery/blob/96dc185a3a3e488f820d06579d85cb4f480a7089/WinUIGallery/Helpers/ThemeHelper.cs#L62
- **AppWindow TitleBar doesn't update caption button colors correctly
when changed while app is running:**
https://github.com/microsoft/WinUI-Gallery/blob/96dc185a3a3e488f820d06579d85cb4f480a7089/WinUIGallery/Helpers/TitleBarHelper.cs#L22


### Screenshot

| Before Fix | After Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/0db22e18-cbcc-4cdc-857e-c1b093497309">
| <video
src="https://github.com/user-attachments/assets/2e53efce-4122-4179-93aa-c549ded74878">
|




### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #12507
Fixes #22058
Fixes #30518 (Windows)
Fixes #30807
Fixes #31819

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

---------

Co-authored-by: Vignesh-SF3580 <vignesh.nagarajan@syncfusion.com>
PureWeen added a commit that referenced this pull request Feb 10, 2026
.NET MAUI inflight/candidate introduces significant improvements across
all platforms with focus on quality, performance, and developer
experience. This release includes 20 commits with various improvements,
bug fixes, and enhancements.


## Blazor
- Fix for BlazorWebView Back Navigation Issues on Android 13+ After
Predictive Back Gesture Changes by @SuthiYuvaraj in
#33213
  <details>
  <summary>🔧 Fixes</summary>

- [Back navigation different between .net 9 and .net 10 blazor
hybrid](#32767)
  </details>

## CollectionView
- [Android] Fix for CollectionView.EmptyView does not remeasure its
height when the parent layout changes dynamically, causing incorrect
sizing. by @BagavathiPerumal in
#33559
  <details>
  <summary>🔧 Fixes</summary>

- [`CollectionView.EmptyView` does not remeasure its height when the
parent layout changes dynamically, causing incorrect
sizing.](#33324)
  </details>

- [Android] Fixed CollectionView reordering last item by @vitalii-vov in
#17825
  <details>
  <summary>🔧 Fixes</summary>

- [Android app crashes when dragging into
CollectionView](#17823)
  </details>

## DateTimePicker
- [iOS] Fix VoiceOver focus not shifting to Picker/DatePicker/TimePicker
popups by @kubaflo in #33152
  <details>
  <summary>🔧 Fixes</summary>

- [Voiceover does not automatically shift focus to the "Category" popup
when it opens.: A11y_Developer balance version .NET
10_Project_ScreenReader](#30746)
  </details>

## Dialogalert
- [iOS 26] Fix DisplayPromptAsync maxLength not enforced due to new
multi-range delegate by @Shalini-Ashokan in
#33616
  <details>
  <summary>🔧 Fixes</summary>

- [[iOS 26.1] DisplayPromptAsync ignores maxLength and does not respect
RTL FlowDirection](#33549)
  </details>

## Flyout
- [iOS] Shell: Account for SafeArea when positioning flyout footer by
@kubaflo in #32891
  <details>
  <summary>🔧 Fixes</summary>

- [[IOS] Footer not displaying in iOS when StackOrientation.Horizontal
is set on FlyoutFooter](#26395)
  </details>

## Fonts
- Hide obsolete FontSize values from IDE autocomplete by @noiseonwires
in #33694

## Gestures
- Android pan fixes by @BurningLights in
#21547
  <details>
  <summary>🔧 Fixes</summary>

- [Flickering occurs while updating the width of ContentView through
PanGestureRecognizer.](#20772)
  </details>

## Navigation
- Shell: Add duplicate route validation for sibling elements by
@SubhikshaSf4851 in #32296
  <details>
  <summary>🔧 Fixes</summary>

- [OnNavigatedTo is not called when navigating from a specific
page](#14000)
  </details>

## Picker
- Improved Unfocus support for Picker on Mac Catalyst by @kubaflo in
#33127
  <details>
  <summary>🔧 Fixes</summary>

- [When using voiceover unable to access expanded list of project combo
box: A11y_.NET maui_user can creat a tak_Screen
reader](#30897)
- [Task and Project controls are not accessible with keyboard:A11y_.NET
maui_User can create a new
task_Keyboard](#30891)
  </details>

## SafeArea
- [iOS] SafeArea: Return Empty for non-ISafeAreaView views (opt-in
model) by @praveenkumarkarunanithi in
#33526
  <details>
  <summary>🔧 Fixes</summary>

- [[iOS] SafeArea is not applied when a ContentPage uses a
ControlTemplate](#33458)
  </details>

## Shell
- [iOS] Fix ObjectDisposedException in TraitCollectionDidChange on
window disposal by @jeremy-visionaid in
#33353
  <details>
  <summary>🔧 Fixes</summary>

- [Intermittent crash on exit on MacCatalyst -
ObjectDisposedException](#33352)
  </details>

- [Issue-Resolver] Explicit fallback for BackButtonBehavior lookup by
@kubaflo in #33204
  <details>
  <summary>🔧 Fixes</summary>

- [Setting BackButtonBehavior to not visible or not enabled does not
work](#28570)
- [BackButtonBehavior not
bound](#33139)
  </details>

## Templates
- [Templates] Remove redundant SemanticProperties.Description attribute
by @kubaflo in #33621
  <details>
  <summary>🔧 Fixes</summary>

- [Task and Project controls are not accessible with keyboard:A11y_.NET
maui_User can create a new
task_Keyboard](#30891)
- [Unable to select "Tags" when Voiceover is turned on.: A11y_Developer
balance version .NET
10_Project_ScreenReader](#30749)
  </details>

## Theme
- [Windows] Fix runtime theme update for controls and TitleBar by
@Tamilarasan-Paranthaman in #31714
  <details>
  <summary>🔧 Fixes</summary>

- [[Windows][MacOS?] Change title bar color when switching light/dark
theme at runtime](#12507)
- [OS system components ignore app
theme](#22058)
- [[Mac Catalyst][Windows] TitleBar not reacting on UserAppTheme
changes](#30518)
- [In dark theme "Back" and "hamburger" button icon color contrast with
background color is less than 3:1: A11y_.NET maui_User can get all the
insights of Dashboard_Non text
Contrast](#30807)
- [`Switch` is invisible on `PointOver` when theme has
changed](#31819)
  </details>

## Theming
- [XSG] Fix Style Setters referencing source-generated bindable
properties by @simonrozsival in
#33562

## Titlebar
- [Windows] Fix TitleBar.IsVisible = false the caption buttons become
unresponsive by @devanathan-vaithiyanathan in
#33256
  <details>
  <summary>🔧 Fixes</summary>

- [When TitleBar.IsVisible = false the caption buttons become
unresponsive on Windows](#33171)
  </details>

## WebView
- Fix WebView JavaScript string escaping for backslashes and quotes by
@StephaneDelcroix in #33726

## Xaml
- [XSG] Fix NaN value in XAML generating invalid code by
@StephaneDelcroix in #33533
  <details>
  <summary>🔧 Fixes</summary>

- [[XSG] NaN value in XAML generates invalid
code](#33532)
  </details>


<details>
<summary>📦 Other (1)</summary>

- Remove InternalsVisibleTo attributes for .NET MAUI Community Toolkit
by @jfversluis via @Copilot in #33442

</details>
**Full Changelog**:
main...inflight/candidate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-theme Themes, theming community ✨ Community Contribution p/0 Current heighest priority issues that we are targeting for a release. partner/syncfusion Issues / PR's with Syncfusion collaboration platform/windows

Projects

Status: Done

8 participants

Comments