Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caption controls don't update to on theme change #210

Closed
RyanLua opened this issue Jan 16, 2025 · 5 comments
Closed

Caption controls don't update to on theme change #210

RyanLua opened this issue Jan 16, 2025 · 5 comments
Labels
bug Something isn't working

Comments

@RyanLua
Copy link

RyanLua commented Jan 16, 2025

When you change the window's theme using Application.RequestedTheme, it doesn't update the caption controls: Minimize button, Maximize/Restore button, and Close button colors making it difficult to see the caption controls

Reproduction

  1. Open the WinUI EX Test App
  2. Go to the Settings page
  3. Change the theme to the opposite you are using (If you're on light theme, change to dark and vice versa)
  4. Notice the caption buttons on the top right are still using the old theme, making it hard to view.

Example of changing from light theme to dark theme.

Image

Image of the issue on my own app using the same steps.

Image

@dotMorten
Copy link
Owner

dotMorten commented Jan 16, 2025

@RyanLua I'm not quite following what captions you refer to. I don't see anything that looks off when following those steps, and screenshots above look fine too.
Also the property you're changing is a WinAppSDK thing and has nothing to do with WinUIEx itself, so more likely an issue in WinUI 3 itself.

@RyanLua
Copy link
Author

RyanLua commented Jan 16, 2025

@RyanLua I'm not quite following what captions you refer to. I don't see anything that looks off when following those steps, and screenshots above look fine too. Also the property you're changing is a WinAppSDK thing and has nothing to do with WinUIEx itself, so more likely an issue in WinUI 3 itself.

By caption buttons, I mean the buttons on the top right of the window. Specifically:

  • Minimize button
  • Maximize/Restore button
  • Close button

Here is a screenshot of what it SHOULD look like but isn't. Highlighted are the caption buttons.

Image

@ghost1372
Copy link
Contributor

ghost1372 commented Jan 16, 2025

@RyanLua if you are using Microsoft TitleBar control, this issue fixed in v1.7-exp2 (related issue in winui repo)
if you are using @dotMorten TitleBar control, he needs to fix Caption Button Foreground whn theme changed.

sample code:

public void UpdateCaptionButtons(Window window)
   {
       if (window == null)
           return;

       var res = Application.Current.Resources;
       Windows.UI.Color buttonForegroundColor;
       Windows.UI.Color buttonHoverForegroundColor;

       Windows.UI.Color buttonHoverBackgroundColor;
       if (ActualTheme == ElementTheme.Dark)
       {
           buttonForegroundColor = ColorHelper.GetColorFromHex("#FFFFFF");
           buttonHoverForegroundColor = ColorHelper.GetColorFromHex("#FFFFFF");

           buttonHoverBackgroundColor = ColorHelper.GetColorFromHex("#0FFFFFFF");
       }
       else
       {
           buttonForegroundColor = DevWinUI.ColorHelper.GetColorFromHex("#191919");
           buttonHoverForegroundColor = ColorHelper.GetColorFromHex("#191919");

           buttonHoverBackgroundColor = ColorHelper.GetColorFromHex("#09000000");
       }
       res["WindowCaptionForeground"] = buttonForegroundColor;

       window.AppWindow.TitleBar.ButtonForegroundColor = buttonForegroundColor;
       window.AppWindow.TitleBar.ButtonHoverForegroundColor = buttonHoverForegroundColor;

       window.AppWindow.TitleBar.ButtonHoverBackgroundColor = buttonHoverBackgroundColor;
   }

@RyanLua
Copy link
Author

RyanLua commented Jan 16, 2025

@ghost1372 I'm using the WinUIEx titlebar control. This is backed up by the fact that is same issue is reproducible in the sample app.

I updated the Windows App SDK from 1.6.241114003 to 1.7.250109001-experimental2 anyways and while the accessibility issue has been resolved, the titlebar looks less than ideal:

Image

dotMorten pushed a commit that referenced this issue Jan 16, 2025
@dotMorten
Copy link
Owner

Fixed!

@dotMorten dotMorten added bug Something isn't working and removed More Info Needed labels Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants