0

So, I'm trying to customize my wpf app a bit, but thought I would be better to leave the title bar as it is and not do a custom title bar. Problem is, the title bar is in light mode altough Windows is set to dark mode. Unfortunately I did not find a proper "guide" which shows how I can support light and dark mode title bars.

Most of the stackoverflow answers said that you should customize the title bar in the styles with custom buttons and everything else, but I'm not sure if this is the best approach.

Does anyone know how to switch the wpf title bar to dark mode (and of course switch it back to light mode)?

I am using WPF with .NET 5 and C# :)

Screenshot of default light mode title bar

I set windows to dark mode (Hell = Light, Dunkel = Dark) Screenshot of theme setting in windows 11

EDIT 1:

I tried the answer in this post How do I get a black Title Bar for dark Mode in WPF Unfortunately I did not work like expected. First of all if I insert the style setter property for the WindowChrome I get an error that the property "WindowChrome" does not exists in the "System.Windows.Shell" namespace.

In the Setter.Value I got the same error. Maybe it is slightly different in .NET 5?

I added this code (I also tried shell:WindowChrome.WindowChrome as the docs said):

<Setter Property="shell:WindowChrome">
    <Setter.Value>
        <shell:WindowChrome />
    </Setter.Value>
</Setter>

And those are the namespaces I tried:

xmlns:shell="System.Windows.Shell"                
xmlns:shell1="http://schemas.microsoft.com/expression/blend/2008"               
xmlns:shell2="http://schemas.microsoft.com/netfx/2009/xaml/presentation"
Dominic Saladin
  • 142
  • 2
  • 8
  • I'm interested in the answer to this as well. I've always just accepted the light bar or made my own. Edit: [this](https://stackoverflow.com/questions/59141916/how-do-i-get-a-black-title-bar-for-dark-mode-in-wpf) seems to answer your question – Nigel Nov 09 '21 at 01:01
  • Does this answer your question? [How do I get a black Title Bar for dark Mode in WPF](https://stackoverflow.com/questions/59141916/how-do-i-get-a-black-title-bar-for-dark-mode-in-wpf) – Nigel Nov 09 '21 at 01:03
  • I just tried that, but unfortunately it did not work. I updated the question – Dominic Saladin Nov 09 '21 at 07:05

1 Answers1

0

There’s actually a dwmapi function that lets change the default title bar between light and dark mode in Windows 10 and 11. It’s actually pretty easy to use. Have a look here for more info: https://codingguides.quinnscomputing.com/2022/05/how-to-enable-dark-title-bar-in-windows.html.