microsoft / microsoft/microsoft-ui-xaml

Text box/block context menu text color not updated on theme change

Open
#11,498 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area-CommandBarFlyout bug team-Controls
Dominant language
C++
Stars
8.4k
Forks
942
Avg merge
2d 7h
Merged PRs (30d)
105

Description

### Describe the bug

Text box/block context menu text color is not updated on theme change (I am setting the `(XamlRoot.Content as FrameworkElement).RequestedTheme` property). The background updates correctly, but not the text, leaving it impossible to read. Possibly an issue with CommandBarFlyout in general.

### Why is this important?

My app allows updating the theme while running. Everything else apart from this works. It worked in UWP.

### Steps to reproduce the bug

Use the following XAML and code behind. Run the app, right click in the text box to show the context menu once, then change the theme using the button, then right click in the text box again and observe the text color of the context menu has not updated. Can do the same with the selection context menu for the text block.

```XAML





````

```C#
using Microsoft.UI.Xaml;

namespace TestContextMenu {
public sealed partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
}
private void changeThemeButton_Click(object sender, RoutedEventArgs e) {
((FrameworkElement)rootElement.XamlRoot.Content).RequestedTheme = ((FrameworkElement)rootElement.XamlRoot.Content).RequestedTheme != ElementTheme.Dark ? ElementTheme.Dark : ElementTheme.Light;
}
}
}
```

### Actual behavior

_No response_

### Expected behavior

_No response_

### Screenshots

_No response_

### NuGet package version

2.3.1

### Windows version

Windows 11 (25H2): Build 26200

### Additional context

_No response_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied XAML reproduction and changeThemeButton_Click, then inspect CommandBarFlyout and context-menu theme handling. Run the example with WinUI 2.3.1 and verify that TextBox and TextBlock selection context-menu text colors update after switching RequestedTheme.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, csharp
Domain
desktop, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.