How to remove accent color in title bar of the window when that option is enabled in Windows 11 22H2?

229 Views Asked by At

In Windows 11 22H2 Microsoft changed how option

Settings > Personalization > Color > Show accent color in title bars and windows borders

works (compared to 21H2). Now it is forced on all windows. Is it possible to disable it on custom windows?

I expected that CaptionHeight would control this, but makes no difference.

<WindowChrome                    
    CaptionHeight="0" 
    GlassFrameThickness="-1"
    UseAeroCaptionButtons="True" />

TitleBar.Height is not changeable.

Any other suggestions or is it a bug in Windows 11 so the Mica effect can be applied on the entire window including the title bar?

1

There are 1 best solutions below

1
mm8 On

You could use the AppWindow class in the Windows App SDK to change the colour of the title bar, e.g.:

Microsoft.Windows.ApplicationModel.DynamicDependency.Bootstrap.TryInitialize(0x00010000, out _);
var hWnd = new System.Windows.Interop.WindowInteropHelper(this).EnsureHandle();
var windowId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(hWnd);
var appWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(windowId);
if (appWindow != null)
{
    appWindow.TitleBar.BackgroundColor = Microsoft.UI.Colors.Red;
}