Skip to content

Conversation

KlausLoeffelmann
Copy link
Member

@KlausLoeffelmann KlausLoeffelmann commented Jun 24, 2025

When a control wants to automatically participate in DarkMode handling, it does so by setting the ControlStyles.ApplyThemingImplicitly flag first thing in the overridden property CreateParams.

For custom control controls, which derive von other controls than controls, and which in addition have already opted in (like ButtonBase) in to auto-DarkMode handling, this PR makes it possible for a control to opt out in the same way.

To this end, the derived custom control also needs to overwrite the CreateParams property, and then needs to clear the ApplyThemingImplicitly flag the first thing before calling the base implementation:

// In CreateParams, do this first to opt an inherited control out of dark mode handling:
SetFlags(ControlStyles.ApplyThemingImplicitly, false);

Note: It may seem redundant, but it's important to clear that flag, even if it can be assumed at this point that the flag has never been set before!

Microsoft Reviewers: Open in CodeFlow

@KlausLoeffelmann KlausLoeffelmann requested a review from a team as a code owner June 24, 2025 00:30
@KlausLoeffelmann KlausLoeffelmann added this to the 10 Preview7 milestone Jun 24, 2025
@github-actions github-actions bot added the area-DarkMode Issues relating to Dark Mode feature label Jun 24, 2025
Copy link

codecov bot commented Jun 24, 2025

Codecov Report

Attention: Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 76.61135%. Comparing base (7069b0a) to head (984f6e5).
Report is 7 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #13642         +/-   ##
===================================================
+ Coverage   76.60680%   76.61135%   +0.00454%     
===================================================
  Files           3253        3253                 
  Lines         641011      641016          +5     
  Branches       47442       47443          +1     
===================================================
+ Hits          491058      491091         +33     
+ Misses        146302      146275         -27     
+ Partials        3651        3650          -1     
Flag Coverage Δ
Debug 76.61135% <91.66667%> (+0.00454%) ⬆️
integration 18.99664% <91.66667%> (+0.00524%) ⬆️
production 51.07506% <91.66667%> (+0.01057%) ⬆️
test 97.41186% <ø> (ø)
unit 48.45300% <91.66667%> (+0.01028%) ⬆️

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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@KlausLoeffelmann KlausLoeffelmann merged commit 16058a3 into dotnet:main Jul 1, 2025
9 checks passed
@KlausLoeffelmann KlausLoeffelmann deleted the DarkModeOptOut branch July 1, 2025 07:11
@github-actions github-actions bot locked and limited conversation to collaborators Jul 31, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-DarkMode Issues relating to Dark Mode feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants