Skip to content

Fix issue 14198: [Dark Mode] Improve visual contrast of the Group Headers in ListView control in dark#14406

Open
SimonZhao888 wants to merge 2 commits intodotnet:mainfrom
SimonZhao888:fix_issue_14198
Open

Fix issue 14198: [Dark Mode] Improve visual contrast of the Group Headers in ListView control in dark#14406
SimonZhao888 wants to merge 2 commits intodotnet:mainfrom
SimonZhao888:fix_issue_14198

Conversation

@SimonZhao888
Copy link
Member

@SimonZhao888 SimonZhao888 commented Mar 18, 2026

Fixes #14198

Proposed changes

Customer Impact

Regression?

  • Yes / No

Risk

Screenshots

Before

After

Test methodology

Accessibility testing

Test environment(s)

@SimonZhao888 SimonZhao888 requested a review from Copilot March 18, 2026 08:26
@SimonZhao888 SimonZhao888 requested a review from a team as a code owner March 18, 2026 08:26
@github-actions github-actions bot added the area-DarkMode Issues relating to Dark Mode feature label Mar 18, 2026
@SimonZhao888 SimonZhao888 changed the title Fix issue 14198: [Dark Mode] Improve visual contrast of the Group Hea… Fix issue 14198: [Dark Mode] Improve visual contrast of the Group Headers in ListView control in dark Mar 18, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR targets WinForms ListView dark mode rendering by improving the visual contrast of group headers (and related group text) when groups are enabled.

Changes:

  • Adds custom dark-mode rendering logic for group header text, chevron, subtitle, and footer.
  • Adjusts custom-draw flags and text color handling to receive group-related draw notifications and control group text colors.
  • Updates the applied dark-mode theme identifier for the ListView/ColumnHeader to use the ItemsView theme.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@SimonZhao888 SimonZhao888 requested a review from Copilot March 19, 2026 02:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves ListView group header readability in dark mode by adjusting theming/custom-draw behavior and adding an overlay render pass to redraw group header/subtitle/footer with higher-contrast styling.

Changes:

  • Add dark-mode overlay drawing for group header/subtitle/footer and a custom chevron/underline rendering path.
  • Adjust ListView custom draw flags/colors so group custom-draw notifications are raised and native group text is suppressed in dark mode.
  • Switch the applied dark-mode theme identifier to DarkMode_ItemsView and attempt to configure group text colors via LVM_SETGROUPMETRICS.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +271 to +276
using Pen chevronPen = new(chevronColor, 2.6f)
{
StartCap = Drawing.Drawing2D.LineCap.Round,
EndCap = Drawing.Drawing2D.LineCap.Round,
LineJoin = Drawing.Drawing2D.LineJoin.Round
};
Comment on lines +297 to +301
using Pen linePen = new(lineColor, 1f)
{
StartCap = Drawing.Drawing2D.LineCap.Round,
EndCap = Drawing.Drawing2D.LineCap.Round
};
Comment on lines +174 to +175
int headerTextX = isRtl ? headerRect.Right - horizontalPadding - headerTextWidth
: headerRect.Left + horizontalPadding;
Comment on lines +254 to +261
int centerX = headerRect.Right - 9;
int centerY = headerTextRect.Top + (headerTextRect.Height / 2) + 1;

Rectangle nativeChevronRect = new(
headerRect.Right - 24,
headerTextRect.Top - 3,
24,
headerTextRect.Height + 8);
Comment on lines 6262 to +6280
if (Application.IsDarkModeEnabled
&& !OwnerDraw
&& nmhdr->code == PInvoke.NM_CUSTOMDRAW)
{
NMLVCUSTOMDRAW* nmlvcd = (NMLVCUSTOMDRAW*)(nint)m.LParamInternal;

if (nmlvcd->nmcd.dwDrawStage == NMCUSTOMDRAW_DRAW_STAGE.CDDS_PREPAINT)
{
// We request the notification for the items to be drawn.
m.ResultInternal = (LRESULT)(nint)PInvoke.CDRF_NOTIFYITEMDRAW;
return true;
}
else if (nmlvcd->nmcd.dwDrawStage == NMCUSTOMDRAW_DRAW_STAGE.CDDS_ITEMPREPAINT)
{
// Setting the current ForeColor to the text color.
PInvokeCore.SetTextColor(nmlvcd->nmcd.hdc, ForeColor);
Color textColor = nmlvcd->dwItemType == NMLVCUSTOMDRAW_ITEM_TYPE.LVCDI_GROUP
? BackColor
: ForeColor;

PInvokeCore.SetTextColor(nmlvcd->nmcd.hdc, textColor);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-DarkMode Issues relating to Dark Mode feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Dark Mode] Improve visual contrast of the Group Headers in ListView control in dark

2 participants