Sitelet https://github.com/dotnet/winforms/pull/15244
Skip to content

Fix Issue - [Dark Mode] The BackColor of the ProgressBar control should not be changed - #15244

Open
Rabina4363sf wants to merge 4 commits into
dotnet:mainfrom
Rabina4363sf:Fix_Issue_11938
Open

Rabina4363sf wants to merge 4 commits into
dotnet:mainfrom
Rabina4363sf:Fix_Issue_11938

Conversation

@Rabina4363sf

@Rabina4363sf Rabina4363sf commented Oct 8, 2026 •

Copy link
Copy Markdown

Fixes #11938

Proposed changes

  • Use SystemColors.ControlDarkDark as the native ProgressBar background in Dark Mode, regardless of a custom BackColor value.
  • Apply the fixed background during control creation, handle creation, and system-color updates; prevent subsequent BackColor changes from updating the native background in Dark Mode.
  • Add ProgressBar_DarkMode_CustomBackColor_DoesNotLeakThroughVisually to verify that the managed property retains the assigned color while the native background uses the dark-mode color.

Customer Impact

  • Setting ProgressBar.BackColor no longer produces an unexpected custom-colored background in Dark Mode, matching the behavior reported for Classic Mode with visual styles enabled.
  • The assigned BackColor property value and change notifications remain available. Non-dark-mode background handling is unchanged.

Regression?

  • No. The issue was reported against the newly introduced Dark Mode feature, rather than previously working behavior in an earlier release.

Risk

  • Low, scoped to ProgressBar background rendering in Dark Mode. Applications relying on custom backgrounds in Dark Mode will intentionally render differently. High Contrast and visual behavior still require manual verification; the new test bypasses its assertions in High Contrast.

Screenshots

Before

image

After

image

Test methodology

  • Added a test that enables Dark Mode, assigns Color.Red , creates the control handle, and checks that BackColor remains red while the native background equals SystemColors.ControlDarkDark . The test restores Classic Mode afterward.
  • Manual reproduction, post-handle property changes, handle recreation, system-color changes, and Classic Mode/High Contrast comparisons have not been verified in this session.

Accessibility testing

NA

Test environment(s)

  • Attempted validation on Windows, OS version 10.0.26200, win-x64, using the repository-local .NET SDK 11.0.100-preview.6.26359.118.
  • Original issue environment: .NET SDK 9.0.100-rc.1.24418.2 with privately built WinForms assemblies from the main branch.
Microsoft Reviewers: Open in CodeFlow

@codecov

codecov Bot commented Oct 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 37.84861%. Comparing base (86b408c) to head (76a00eb).

Additional details and impacted files
@@              Coverage Diff              @@
##                main      #15244   +/-   ##
=============================================
  Coverage   37.84861%   37.84861%           
=============================================
  Files            246         246           
  Lines           9789        9789           
  Branches        1031        1031           
=============================================
  Hits            3705        3705           
  Misses          5920        5920           
  Partials         164         164           
Flag Coverage Δ
Debug 37.84861% <ø> (ø)
production 40.04608% <ø> (ø)
test 20.64923% <ø> (ø)
unit 40.04608% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Dark Mode] The BackColor of the ProgressBar control should not be changed

1 participant