diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs index 12cdcc62739..ea1676bb9af 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs @@ -163,6 +163,7 @@ public unsafe partial class Control : internal const string ExplorerThemeIdentifier = "Explorer"; internal const string ItemsViewThemeIdentifier = "ItemsView"; internal const string ComboBoxButtonThemeIdentifier = "CFD"; + internal const string BannerContainerThemeIdentifier = "FileExplorerBannerContainer"; private const short PaintLayerBackground = 1; private const short PaintLayerForeground = 2; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TabControl/TabControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TabControl/TabControl.cs index a2b962ca701..e7f29d89f80 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TabControl/TabControl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TabControl/TabControl.cs @@ -1289,6 +1289,14 @@ protected override void OnHandleCreated(EventArgs e) } UpdateTabSelection(false); + +#pragma warning disable WFO5001 + if (Application.IsDarkModeEnabled) + { + PInvoke.SetWindowTheme(HWND, null, $"{DarkModeIdentifier}::{BannerContainerThemeIdentifier}"); + PInvokeCore.EnumChildWindows(this, StyleChildren); + } +#pragma warning restore WFO5001 } protected override void OnHandleDestroyed(EventArgs e) @@ -1771,6 +1779,10 @@ private bool ShouldSerializeItemSize() return !_padding.Equals(s_defaultPaddingPoint); } + private BOOL StyleChildren(HWND handle) => + PInvoke.SetWindowTheme(handle, $"{DarkModeIdentifier}_{ExplorerThemeIdentifier}", null) + .Succeeded; + /// /// Returns a string representation for this control. ///