I have a WinForms application which automatically adjusts to the dark/light theme on Windows 10. My problem is that the title bar of my window always stays white, regardless which theme the user selects.

Top is current, bottom is how I want it (simulated with Photoshop)
See explorer for example. That is not an UWP app, however it uses a dark title bar on Windows 1903 and newer (when a dark theme is selected).
How can I achieve the same thing? I do not want to use any custom titlebar as I want the application to look and behave like any native application on older Windows versions as well.

Application.SetDefaultDarkMode(DarkMode.Enabled)in Program.cs. You can useDarkMode.Inheritto inherit the current theme from Windows settings. It can be light or dark.