Skip to content

[release/11.0] Enable DataGridView dark mode theming via AppContext switch - #15073

Draft
github-actions[bot] wants to merge 1 commit into
release/11.0from
backport/pr-14267-to-release/11.0
Draft

[release/11.0] Enable DataGridView dark mode theming via AppContext switch#15073
github-actions[bot] wants to merge 1 commit into
release/11.0from
backport/pr-14267-to-release/11.0

Conversation

@github-actions

@github-actions github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Backport of #14267 to release/11.0

Fixes bug #14266

Proposed changes

  • Add an AppContext switch (System.Windows.Forms.DataGridViewDarkModeTheming) to allow applications to opt out of the new dark mode rendering.
  • Update DataGridView colors and painting logic to improve readability and visual consistency in dark mode, including link cells, checkbox cells, combo box cells, and sort glyphs.
  • Preserve existing behavior when the AppContext switch is disabled.

Customer Impact

  • DataGridView automatically uses improved dark mode rendering by default, providing better readability and contrast while allowing applications to opt out if needed.

Testing

  • Unit test and manual test

Risk

  • Minimal

Regression?

  • No

## Proposed changes

-  Introduce an AppContext quirk switch `System.Windows.Forms.DataGridViewDarkModeTheming` (exposed via LocalAppContextSwitches / AppContextSwitches) to control whether DataGridView uses dark-mode-specific theming, defaulting to **enabled** for .NET 10 and allowing apps to opt out.
- Add `ApplyDarkModeTheming` in DataGridView and call it only when dark mode is active and the new switch is enabled, centralizing the dark palette (background, gridlines, header/row colors) for high contrast on dark backgrounds.
- Update DataGridView painting logic for several cell types—core cells, checkbox cells, combo box cells, and column header cells (**sort glyphs**)—to use adjusted colors and rendering that remain legible and visually correct in dark mode.
- Improve DataGridViewLinkCell in dark mode by using shared `LinkUtilities` link colors (aligned with LinkLabel’s dark colors) and ensuring selected links render with appropriate selection foreground color for sufficient contrast.
- Keep existing light-mode/legacy behavior unchanged when the AppContext switch is disabled, so existing applications can retain their current appearance without code changes.

## Customer Impact

- Users get a DataGridView that automatically renders with readable, high-contrast colors in dark mode by default, while app developers can still opt out via an AppContext switch to preserve existing light-themed behavior if needed.
@github-actions
github-actions Bot requested a review from a team as a code owner September 10, 2026 02:07
@LeafShi1
LeafShi1 marked this pull request as draft September 10, 2026 08:59
@dotnet-policy-service dotnet-policy-service Bot added the draft draft PR label Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

draft draft PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant