microsoft-ui-xaml icon indicating copy to clipboard operation
microsoft-ui-xaml copied to clipboard

RequestTheme cannot take effect on caption button

Open BigHeadDev opened this issue 3 months ago • 3 comments

Describe the bug

I plan to implement a black and white theme switching function. For other elements, it works normally, but for the caption buttons in the upper right corner have a confusing response to theme switching

Steps to reproduce the bug

1.Use the TitleBar control provided by WAS 1.7 as the title bar 2.MainWindow.xaml

<Grid
    x:Name="root"
    d:DataContext="{d:DesignInstance Type=vm:MainViewModel}"
    Loaded="root_Loaded">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition />
    </Grid.RowDefinitions>

    <TitleBar x:Name="titleBar"/>
    <OtherElement Grid.Row="1"/>
</Grid>

3.MainWindow.xaml.cs

public MainWindow() {
    this.InitializeComponent();
    ExtendsContentIntoTitleBar = true;
    AppWindow.TitleBar.ExtendsContentIntoTitleBar = true;
    AppWindow.TitleBar.PreferredHeightOption = TitleBarHeightOption.Tall;
    AppWindow.SetIcon("favicon.ico");
    AppWindow.Title = titleBar.Title = AppInfo.Current.DisplayInfo.DisplayName;
    SetTitleBar(titleBar);
}

4.Change root's RequestTheme

  • My Windows Theme:Light
  • root's RequestTheme:Dark

but My application 👇👇👇

【Active】

- It is difficult for the eyes to detect caption buttons
Image

【Not Active】 Image

Expected behavior

Fixed the color display confusion of caption buttons in the form activation state after switching RequestTheme

Screenshots

No response

NuGet package version

Windows App SDK 1.7.3: 1.7.250606001

Packaging type

Packaged (MSIX)

Windows version

Windows 11 version 23H2 (22631, June 2025 Update)

IDE

Visual Studio 2022

Additional context

No response

BigHeadDev avatar Aug 31 '25 16:08 BigHeadDev

Yeah, this has been a bug/problem for years. Even the TemplateStudio had this exact problem. And Microsoft has clearly abandoned TemplateStudio also...(it's been inactive for years). So, I had to manually change the color in code behind like this. TitleBar.ButtonForegroundColor = Colors.White; or black or whatever every time theme and active state is changed.

torum avatar Sep 19 '25 02:09 torum

Yeah, this has been a bug/problem for years. Even the TemplateStudio had this exact problem. And Microsoft has clearly abandoned TemplateStudio also...(it's been inactive for years). So, I had to manually change the color in code behind like this. or black or whatever every time theme and active state is changed.TitleBar.ButtonForegroundColor = Colors.White;

Microsoft......🐶

BigHeadDev avatar Sep 19 '25 03:09 BigHeadDev

Did you try to use Window.AppWindow.TitleBar.PreferredTheme = Microsoft.UI.Windowing.TitleBarTheme.UseDefaultAppMode;?

bogdan-patraucean avatar Nov 15 '25 20:11 bogdan-patraucean