Skip to content

Commit a846464

Browse files
Fixes darkmode issue in ComboBoxRenderer.
1 parent 936ca97 commit a846464

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/System.Windows.Forms/System/Windows/Forms/Control.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ public unsafe partial class Control :
163163
internal const string ItemsViewThemeIdentifier = "ItemsView";
164164
internal const string ComboBoxButtonThemeIdentifier = "CFD";
165165
internal const string BannerContainerThemeIdentifier = "FileExplorerBannerContainer";
166+
internal const string ComboboxClassIdentifier = "COMBOBOX";
166167

167168
private const short PaintLayerBackground = 1;
168169
private const short PaintLayerForeground = 2;

src/System.Windows.Forms/System/Windows/Forms/Controls/ComboBox/ComboBoxRenderer.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ public static class ComboBoxRenderer
1414
// Make this per-thread, so that different threads can safely use these methods.
1515
[ThreadStatic]
1616
private static VisualStyleRenderer? t_visualStyleRenderer;
17-
private static readonly VisualStyleElement s_comboBoxElement = VisualStyleElement.ComboBox.DropDownButton.Normal;
17+
18+
#pragma warning disable WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
19+
20+
private static readonly VisualStyleElement s_comboBoxElement = Application.IsDarkModeEnabled
21+
? VisualStyleElement.CreateElement($"{Control.DarkModeIdentifier}_{Control.ComboBoxButtonThemeIdentifier}::{Control.ComboboxClassIdentifier}", 1, 1)
22+
: VisualStyleElement.ComboBox.DropDownButton.Normal;
23+
24+
#pragma warning restore WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
25+
1826
private static readonly VisualStyleElement s_textBoxElement = VisualStyleElement.TextBox.TextEdit.Normal;
1927

2028
/// <summary>

src/System.Windows.Forms/System/Windows/Forms/Controls/ListView/ListView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4551,7 +4551,7 @@ protected override void OnHandleCreated(EventArgs e)
45514551
// This not noticeable if the customer paints the items w/ the same background color as the list view itself.
45524552
// However, if the customer paints the items w/ a color different from the list view's back color
45534553
// then when the user changes selection the native list view will not invalidate the entire list view item area.
4554-
// PInvokeCore.SendMessage(this, PInvoke.LVM_SETTEXTBKCOLOR, (WPARAM)0, (LPARAM)PInvokeCore.CLR_NONE);
4554+
PInvokeCore.SendMessage(this, PInvoke.LVM_SETTEXTBKCOLOR, (WPARAM)0, (LPARAM)PInvokeCore.CLR_NONE);
45554555

45564556
// LVS_NOSCROLL does not work well when the list view is in View.Details or in View.List modes.
45574557
// we have to set this style after the list view was created and before we position the native list view items.

0 commit comments

Comments
 (0)