[Windows] Fixed: Setting BackgroundColor for Slider updates the MaximumTrackColor#30089
Conversation
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue on Windows where setting the Slider BackgroundColor incorrectly overrides the MaximumTrackColor by updating the slider’s container background resources. The changes include:
- Refactoring update methods in SliderExtensions.cs to use a common UpdateColor helper.
- Extending the SliderHandler mapping to include background color on Windows.
- Adding new tests in TestCases.Shared.Tests and TestCases.HostApp to verify the fix.
Reviewed Changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Core/src/Platform/Windows/SliderExtensions.cs | Refactored resource update methods and added UpdateBackgroundColor for proper slider background handling. |
| src/Core/src/Handlers/Slider/SliderHandler.cs | Updated the command mapper by adding a Windows-specific mapping for the Background property. |
| src/Core/src/Handlers/Slider/SliderHandler.Windows.cs | Introduced MapBackgroundColor to invoke the new background update on Windows sliders. |
| src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue25921.cs | Added a NUnit test to verify the slider’s color behavior on Windows. |
| src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla29128.cs | Cleaned up obsolete preprocessor code related to background color tests. |
| src/Controls/tests/TestCases.HostApp/Issues/Issue25921.cs | Added a host app test page for manual verification of issue 25921. |
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/rebase |
c375de5 to
7226f91
Compare
7226f91 to
551ba44
Compare
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 30089Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 30089" |
🤖 AI Summary📊 Expand Full Review —
|
| # | Source | Approach | Test Result | Files Changed | Notes |
|---|---|---|---|---|---|
| PR | PR #30089 | Map ISlider.Background on Windows to slider container background resources instead of letting it visually override the maximum track; refactor slider color updates through a shared helper. |
PENDING (Gate) | src/Core/src/Handlers/Slider/SliderHandler.cs, src/Core/src/Handlers/Slider/SliderHandler.Windows.cs, src/Core/src/Platform/Windows/SliderExtensions.cs |
Original PR |
Issue: #25921 - [Windows] Setting BackgroundColor for Slider updates the Maximum Track Color
PR: #30089 - [Windows] Fixed: Setting BackgroundColor for Slider updates the MaximumTrackColor
Author: Tamilarasan-Paranthaman (partner/syncfusion)
Status: ✅ MERGED (2026-03-21T23:34:55Z)
Target Branch: inflight/current
Platforms Affected: Windows (bug); all platforms tested by author
Files Changed: 3 implementation, 3 test source, 15 snapshots
Key Findings
- Windows-specific bug: setting
Slider.BackgroundColorvisually overridesMaximumTrackColorbecause the default WinUI slider template uses the control'sBackgroundproperty path for rendering the unfilled track (SliderTrackFillresources). WhenBackgroundis set it occupies the same visual layer as the maximum track color. - During PointerOver/Pressed states WinUI correctly applies
MaximumTrackColortoHorizontalTrackRect, making the max track color only visible on hover — confirming the template/background conflict as the root cause. - The PR fixes this by adding a Windows-only mapper (
MapBackgroundColor) that redirects background updates to theSliderContainerBackground*theme resources instead of letting the background propagate through the genericView.Backgroundpath. SliderExtensions.csrefactored: extracted a sharedUpdateColorhelper, eliminating per-method repetition acrossUpdateMinimumTrackColor,UpdateMaximumTrackColor,UpdateThumbColor, and newUpdateBackgroundColor.Bugzilla29128.cshad a#if TEST_FAILS_ON_WINDOWSguard that blocked the test on Windows; removed since the underlying bug is now fixed — important correctness improvement.- Review thread: reviewer requested a second Slider using
Background(notBackgroundColor) plus a Button to test dynamic color update; author complied. - Prior agent review (MauiBot, 2026-03-21): all phases COMPLETE, Gate PASSED on Windows, Try-Fix COMPLETE (5/5 passing), Final Recommendation: APPROVE.
Technical Notes
MapBackgroundColoris placed inside a#if WINDOWSblock in the cross-platformSliderHandler.csMapper dictionary, which is the established pattern when a mapper entry is purely platform-specific.MapBackgroundColorisinternalinSliderHandler.Windows.cs(other map methods arepublic) — intentional since this is a Windows-only internal implementation detail, not part of the shared public surface.- Both
BackgroundColorandBackgroundon the MAUIViewultimately flow through theIView.Backgroundproperty to the mapper, so the single mapper key covers both cases. - The
UpdateColorhelper accepts aSliderbase type, andUpdateBackgroundColoracceptsMauiSlider(which extendsSlider), making the internal upcast correct.
Fix Candidates
| # | Source | Approach | Test Result | Files Changed | Notes |
|---|---|---|---|---|---|
| PR | PR #30089 | Add Windows-only Background mapper that routes to SliderContainerBackground* theme resources; refactor existing color methods to use shared UpdateColor helper |
⏳ PENDING (Gate) | SliderHandler.cs, SliderHandler.Windows.cs, SliderExtensions.cs |
Original PR |
Issue: #25921 - [Windows] Setting BackgroundColor for Slider updates the Maximum Track Color
PR: #30089 - [Windows] Fixed: Setting BackgroundColor for Slider updates the MaximumTrackColor
Author: Tamilarasan-Paranthaman (partner/syncfusion)
Status: ✅ MERGED (2026-03-21T23:34:55Z)
Target Branch: inflight/current
Platforms Affected: Windows (bug); all platforms tested by author
Files Changed: 3 implementation files, 3 test source files, 15 snapshot files
Key Findings
- Root Cause: On Windows, the WinUI slider template maps the control's
Backgroundproperty to the same visual channel used to render the unfilled (maximum) track (SliderTrackFillresources). WhenSlider.Backgroundis set via MAUI's genericViewMapper, it occupies that visual slot and overridesMaximumTrackColorin the Normal state. The MaximumTrackColor only appears on PointerOver/Pressed states because those states explicitly apply it toHorizontalTrackRect. - Fix approach: Adds a Windows-only
Backgroundmapper entry (MapBackgroundColor) that routes background updates toSliderContainerBackground*theme resources instead of the visual override path. - Refactor: Extracted shared
UpdateColor(Slider, string[], Brush?)helper, eliminating duplicated code acrossUpdateMinimumTrackColor,UpdateMaximumTrackColor, andUpdateThumbColor. - Test guard removal:
Bugzilla29128.cshad a#if TEST_FAILS_ON_WINDOWSguard because this exact bug caused that test to fail on Windows; removed since the fix resolves it. - Review feedback addressed: Reviewer (jsuarezruiz) requested a second Slider using
Background(notBackgroundColor) plus a Button to test dynamic color update. Author complied. - Prior agent review: MauiBot ran a prior review on 2026-03-21 (Gate ✅ PASSED on Windows).
Technical Notes
MapBackgroundColoris placed inside a#if WINDOWSblock in cross-platformSliderHandler.cs— established MAUI pattern for platform-specific mapper entries.MapBackgroundColoris declaredinternalinSliderHandler.Windows.cswhile all other map methods arepublic. This is a potential concern: it cannot be overridden from user-code custom mappers that reference the method by name.- Both
BackgroundColorandBackgroundon the MAUIViewflow throughIView.Backgroundto the mapper, so the single mapper key covers both cases. UpdateBackgroundColoracceptsMauiSlider(which extendsSlider), consistent withUpdateThumbImageSourceAsync.BackgroundColorResourceKeysarray covers all 4 visual states (Normal, PointerOver, Pressed, Disabled).
Fix Candidates
| # | Source | Approach | Test Result | Files Changed | Notes |
|---|---|---|---|---|---|
| PR | PR #30089 | Add Windows-only Background mapper routing to SliderContainerBackground* theme resources; refactor color helpers to shared UpdateColor |
⏳ PENDING (Gate) | SliderHandler.cs, SliderHandler.Windows.cs, SliderExtensions.cs |
Original PR |
🚦 Gate — Test Verification
Gate Result: ✅ PASSED
Platform: windows
Mode: Full Verification
- Tests FAIL without fix: ✅
- Tests PASS with fix: ✅
- Notes: Issue25921 Slider color test correctly fails without the fix (1.57% visual difference in snapshot), and passes with the fix applied. Full verification successful - tests properly validate the Slider color rendering fix.
Gate Result: ✅ PASSED
Platform: windows
Mode: Full Verification
Tests Detected
| # | Type | Test Name | Filter |
|---|---|---|---|
| 1 | UITest | Issue25921 | Issue25921 |
| 2 | UITest | Bugzilla29128 | Bugzilla29128 |
Verification
| Step | Expected | Actual | Result |
|---|---|---|---|
| Tests WITHOUT fix | FAIL | FAIL (1.57% visual difference in snapshot VerifySliderColors.png) |
✅ |
| Tests WITH fix | PASS | PASS (1 test passed, 0 failed) | ✅ |
Fix Files Reverted (for broken baseline)
src/Core/src/Handlers/Slider/SliderHandler.cssrc/Core/src/Handlers/Slider/SliderHandler.Windows.cssrc/Core/src/Platform/Windows/SliderExtensions.cs
Evidence
Without fix:
Failed VerifySliderColors [3 s]
VisualTestFailedException: Snapshot different than baseline: VerifySliderColors.png (1.57% difference)
Total tests: 1 Failed: 1
The slider's BackgroundColor was incorrectly overriding the MaximumTrackColor rendering — exactly the bug described in issue #25921.
With fix:
Passed VerifySliderColors [1 s]
Test Run Successful.
Total tests: 1 Passed: 1
Gate Result: ✅ PASSED
Platform: windows
Mode: Full Verification
- Tests FAIL without fix: ✅ (VerifySliderColors failed with 1.57% visual diff — BackgroundColor overwriting MaximumTrackColor rendering)
- Tests PASS with fix: ✅ (1 test passed, screenshot matches baseline)
Tests Verified
| # | Type | Test Name | Filter |
|---|---|---|---|
| 1 | UITest | Issue25921 | Issue25921 |
Fix Files Reverted (for broken baseline)
src/Core/src/Handlers/Slider/SliderHandler.cssrc/Core/src/Handlers/Slider/SliderHandler.Windows.cssrc/Core/src/Platform/Windows/SliderExtensions.cs
Evidence
Without fix:
Failed VerifySliderColors [4s]
VisualTestFailedException: Snapshot different than baseline: VerifySliderColors.png (1.57% difference)
Total tests: 1 Failed: 1
With fix:
Passed VerifySliderColors [~1s]
Test Run Successful.
Total tests: 1 Passed: 1
🔧 Fix — Analysis & Comparison
Gate Result: ✅ PASSED
Platform: windows
Mode: Full Verification
- Tests FAIL without fix: ✅
- Tests PASS with fix: ✅
- Notes: Issue25921 Slider color test correctly fails without the fix (1.57% visual difference in snapshot), and passes with the fix applied. Full verification successful - tests properly validate the Slider color rendering fix.
Gate Result: ✅ PASSED
Platform: windows
Mode: Full Verification
Tests Detected
| # | Type | Test Name | Filter |
|---|---|---|---|
| 1 | UITest | Issue25921 | Issue25921 |
| 2 | UITest | Bugzilla29128 | Bugzilla29128 |
Verification
| Step | Expected | Actual | Result |
|---|---|---|---|
| Tests WITHOUT fix | FAIL | FAIL (1.57% visual difference in snapshot VerifySliderColors.png) |
✅ |
| Tests WITH fix | PASS | PASS (1 test passed, 0 failed) | ✅ |
Fix Files Reverted (for broken baseline)
src/Core/src/Handlers/Slider/SliderHandler.cssrc/Core/src/Handlers/Slider/SliderHandler.Windows.cssrc/Core/src/Platform/Windows/SliderExtensions.cs
Evidence
Without fix:
Failed VerifySliderColors [3 s]
VisualTestFailedException: Snapshot different than baseline: VerifySliderColors.png (1.57% difference)
Total tests: 1 Failed: 1
The slider's BackgroundColor was incorrectly overriding the MaximumTrackColor rendering — exactly the bug described in issue #25921.
With fix:
Passed VerifySliderColors [1 s]
Test Run Successful.
Total tests: 1 Passed: 1
Fix Candidates
| # | Source | Approach | Test Result | Files Changed | Notes |
|---|---|---|---|---|---|
| 1 | try-fix attempt-1 (claude-opus-4.6) | RegisterPropertyChangedCallback in MauiSlider.OnApplyTemplate — intercept Background, reroute to SliderContainerBackground*, clear BackgroundProperty |
✅ PASS (3 iters) | 1 file (MauiSlider.cs) |
Self-contained; adds re-entrancy guard complexity |
| 2 | try-fix attempt-2 (claude-sonnet-4.6) | RegisterPropertyChangedCallback in SliderHandler.OnPlatformViewLoaded — handler-level interception, reroute to container resources, unregister in DisconnectHandler |
✅ PASS (3 iters) | 1 file (SliderHandler.Windows.cs) |
Adds lifecycle register/unregister complexity |
| 3 | try-fix attempt-3 (gpt-5.3-codex) | Mapper.ReplaceMapping<IView, ISliderHandler>(nameof(IView.Background), ...) in static ctor — override inherited background mapping |
✅ PASS | 2 files | Elegant but less discoverable than mapper entry |
| 4 | try-fix attempt-4 (gemini-3-pro-preview) | OnApplyTemplate grabs HorizontalTrackRect/VerticalTrackRect; set Fill directly bypassing TemplateBinding |
✅ PASS (2 iters) | 2 files | Critical gap: doesn't fix when MaximumTrackColor is NOT set — Background still overrides track |
| PR | PR #30089 | Windows-only mapper entry [nameof(ISlider.Background)] = MapBackgroundColor routing to SliderContainerBackground*; refactor to shared UpdateColor |
✅ PASSED (Gate) | 3 files | Original PR |
Cross-Pollination
| Model | Round | New Ideas? | Details |
|---|---|---|---|
| claude-opus-4.6 | 2 | No | "Approaches comprehensive — all viable patterns covered" |
| claude-sonnet-4.6 | 2 | Yes | Custom ControlTemplate in XAML (too invasive — maintenance burden) |
| gpt-5.3-codex | 2 | Yes | MaximumTrackBrush DP on MauiSlider (requires custom ControlTemplate to wire up) |
| gemini-3-pro-preview | 2 | Yes | Wrap MauiSlider in Border container (invasive — changes view hierarchy) |
| claude-opus-4.6 | 3 | Yes | Let ViewHandler.MapBackground run normally then re-stamp MaximumTrackColor; limitation: doesn't fix max-track-not-set case |
| claude-sonnet-4.6 | 3 | Yes | RegisterPropertyChangedCallback on BackgroundProperty in MauiSlider constructor, re-apply _maximumTrackBrush reactively |
| gpt-5.3-codex | 3 | Yes | Register FillProperty callback on the track Rectangle itself to re-apply _maximumTrackBrush if TemplateBinding overwrites it |
| gemini-3-pro-preview | 3 | Yes | Conditional background mapper — skip setting native Background if MaximumTrackColor is set |
Exhausted: Yes (max 3 rounds completed; Round 2–3 ideas are variants of callback/DP patterns or have known limitations)
Selected Fix: PR #30089 — Reasons:
- Most complete: Handles null background reset correctly (RemoveKeys when brush is null); fixes the issue whether or not MaximumTrackColor is set (Attempt 4 fails here)
- Simplest and most explicit: Mapper entry pattern is well-established in MAUI; immediately discoverable
- Consistent: Follows same pattern as MinimumTrackColor, MaximumTrackColor, ThumbColor handlers
- Bonus refactor: The shared
UpdateColorhelper eliminates duplicated code across 3 methods - No lifecycle complexity: No callbacks to register/unregister (Attempts 1 & 2); no re-entrancy guards needed
📋 Report — Final Recommendation
Final Recommendation: APPROVE
Phase Status
| Phase | Status | Notes |
|---|---|---|
| Pre-Flight | COMPLETE | Linked issue #25921 confirmed as Windows-only slider rendering bug; PR scope and tests classified. |
| Gate | PASSED | Windows full verification proved Issue25921 fails without the fix and passes with the fix. |
| Try-Fix | COMPLETE | 5 attempts, 5 passing; exploration exhausted after a second cross-pollination round with no new ideas. |
| Report | COMPLETE |
Summary
PR #30089 fixes a real Windows-specific slider bug and includes a UI test that genuinely reproduces it. The gate phase passed in both directions, and the mandatory try-fix exploration found several working alternatives, but none beat the PR's implementation on overall fit for the codebase.
Root Cause
On Windows, the slider template uses the control background path in a way that causes Background to visually override the maximum track when both are set. The bug appears because the background is being applied through the same visual channel that the unfilled track relies on.
Fix Quality
The PR fixes the issue in the right layer for this codebase: a Windows-scoped slider mapper that routes background updates to the slider container resources, alongside a small refactor that keeps slider color updates consistent. Compared with the alternatives, it avoids public API churn, avoids broad changes to shared control helpers, and avoids brittle dependence on WinUI template-part internals while still keeping the logic explicit and maintainable.
✅ Final Recommendation: APPROVE
Phase Status
| Phase | Status | Notes |
|---|---|---|
| Pre-Flight | ✅ COMPLETE | Linked issue #25921 confirmed as Windows-only slider rendering conflict between Background and MaximumTrackColor |
| Gate | ✅ PASSED | Windows full verification: Issue25921 fails without fix (1.57% visual diff), passes with fix |
| Try-Fix | Explicitly skipped per review instructions; prior agent review (MauiBot) ran 5 attempts, all passing, all exhausted | |
| Report | ✅ COMPLETE |
Summary
PR #30089 fixes a real Windows-specific bug where setting Slider.BackgroundColor visually overrides MaximumTrackColor because both shared the same visual layer in the WinUI slider template. The Gate phase confirmed the fix on Windows with full before/after verification. The PR is well-structured, test coverage is present and effective, and a pre-existing test workaround (#if TEST_FAILS_ON_WINDOWS in Bugzilla29128.cs) was correctly removed as part of the fix.
Root Cause
On Windows, the WinUI slider template maps the control's Background property to the same visual path used to render the unfilled (maximum) track (SliderTrackFill resources). When Slider.Background is set via MAUI's background mapper, it occupies that visual slot and overrides whatever was set for MaximumTrackColor in the Normal state. The max track color only appeared on PointerOver/Pressed because those visual states explicitly apply MaximumTrackColor to HorizontalTrackRect. The fix routes background updates to SliderContainerBackground* resources (the slider root container background), which do not conflict with track rendering.
Fix Quality
Strong. The implementation:
- Adds a Windows-only
#if WINDOWSmapper entry in the cross-platformSliderHandler.cs— consistent with the project's pattern for platform-specific mapper overrides. - Adds an
internalMapBackgroundColormethod inSliderHandler.Windows.csthat delegates toMauiSlider.UpdateBackgroundColor()— correct access level for a Windows-only, non-public concern. - Refactors
SliderExtensions.csto extract a sharedUpdateColor(Slider, string[], Brush?)helper, removing 3× duplicated code blocks fromUpdateMinimumTrackColor,UpdateMaximumTrackColor, andUpdateThumbColor. - Covers all four visual states (Normal, PointerOver, Pressed, Disabled) for
SliderContainerBackground. - The HostApp page tests both
BackgroundColor(Yellow) andBackground(Grey → Salmon via button) on separate sliders, providing good dynamic coverage. - The
Bugzilla29128test guard removal is correct — that test was disabled on Windows specifically because of this bug.
Potential Concerns (Minor)
#if WINDOWSin mapper dictionary: While valid and used elsewhere in the codebase, this pattern mixes conditional compilation into an otherwise cross-platform declaration. An alternative would be apartialclass override, but the current approach matches existing MAUI patterns and is acceptable.- No
BackgroundColornull reset path explicitly tested: The HostApp page does not test what happens whenBackgroundColoris reset tonull/Colors.Defaultafter being set. However, theUpdateColorhelper correctly callsRemoveKeyswhenbrush is null, so the path exists. - Snapshot-only test coverage:
VerifySliderColorsrelies entirely on screenshot comparison. This is appropriate for a visual rendering bug, but makes the test sensitive to rendering variance across machines. The existing snapshot approach is consistent with other Slider tests in the project.
✅ Final Recommendation: APPROVE
Phase Status
| Phase | Status | Notes |
|---|---|---|
| Pre-Flight | ✅ COMPLETE | Issue #25921 confirmed Windows-only slider rendering conflict between Background and MaximumTrackColor; 3 impl files + 3 test files classified |
| Gate | ✅ PASSED | Windows full verification: Issue25921 fails without fix (1.57% visual diff), passes with fix |
| Try-Fix | ✅ COMPLETE | 4 attempts (3 rounds cross-pollination); 4/4 passing; PR's fix selected as best |
| Report | ✅ COMPLETE |
Summary
PR #30089 fixes a real Windows-specific bug where setting Slider.BackgroundColor visually overrides MaximumTrackColor because the WinUI slider template maps Control.Background to the same visual path as the unfilled track (SliderTrackFill resources). The Gate confirmed the fix on Windows with full before/after verification (1.57% visual diff without fix, clean pass with fix). The 4-model try-fix exploration found 4 alternative passing approaches, but the PR's mapper-based solution is the best overall fit.
Root Cause
On Windows, the WinUI Slider template uses {TemplateBinding Background} to fill the unfilled track (HorizontalTrackRect.Fill). MAUI's generic ViewHandler.ViewMapper maps IView.Background directly to the WinUI Slider.Background property. When a user sets Slider.BackgroundColor, it flows through this path and occupies the same visual slot as MaximumTrackColor (which writes to SliderTrackFill* resources in the control's resource dictionary). The MaximumTrackColor resource-dictionary approach loses to the TemplateBinding in the Normal state, making the max track color only visible in PointerOver/Pressed states (where WinUI's template explicitly applies MaximumTrackColor to the rect).
Fix Quality
Strong. The implementation:
- Adds a Windows-only
#if WINDOWSmapper entry[nameof(ISlider.Background)] = MapBackgroundColorin cross-platformSliderHandler.cs— the established MAUI pattern for platform-specific mapper overrides (consistent with other patterns in the codebase) - Adds
MapBackgroundColorinSliderHandler.Windows.csdelegating tomauiSlider.UpdateBackgroundColor()— correct separation of mapper dispatch from platform logic - Adds
UpdateBackgroundColor/UpdateColorshared helper inSliderExtensions.csrouting background toSliderContainerBackground*resources — covers all 4 visual states (Normal, PointerOver, Pressed, Disabled) and handles null reset viaRemoveKeys - Removes the
#if TEST_FAILS_ON_WINDOWSguard fromBugzilla29128.cs— correct, since this guard existed specifically because of this bug - HostApp page tests both
BackgroundColor(Yellow, static) andBackground(Grey → Salmon via button, dynamic), providing good coverage
Try-Fix Comparison
| # | Approach | Result | Files | Selected? |
|---|---|---|---|---|
| PR | Mapper entry → SliderContainerBackground* resources |
✅ | 3 | ✅ Best |
| 1 | RegisterPropertyChangedCallback in MauiSlider.OnApplyTemplate |
✅ | 1 | ❌ Re-entrancy guard complexity |
| 2 | RegisterPropertyChangedCallback in SliderHandler.OnPlatformViewLoaded |
✅ | 1 | ❌ Lifecycle register/unregister complexity |
| 3 | Mapper.ReplaceMapping in static constructor |
✅ | 2 | ❌ Less discoverable |
| 4 | Template-part Fill override in OnApplyTemplate |
✅ | 2 | ❌ Doesn't fix when MaximumTrackColor is unset |
Why PR wins: Most explicit, most consistent with MAUI codebase conventions, complete solution (handles null reset), no lifecycle hooks or re-entrancy guards needed. The refactoring to UpdateColor is a bonus that improves code quality.
Potential Concerns (Minor)
MapBackgroundColorisinternalwhile other map methods arepublic: All other mapper methods (MapMinimumTrackColor,MapThumbColor, etc.) inSliderHandler.Windows.csarepublic static. MakingMapBackgroundColorinternalmeans it cannot be referenced by name from external custom mapper configurations. This is likely intentional (Windows-only detail), but should be consistent with other methods for discoverability. Low severity.- No unit test for null reset path: The HostApp page doesn't test resetting
BackgroundColorback tonull/Colors.Defaultafter setting it. The code path exists (RemoveKeyswhen brush is null) but has no test coverage. Low risk given the sharedUpdateColorhelper is used for all other colors. - Snapshot-only test coverage:
VerifySliderColorsrelies entirely on screenshot comparison. This is appropriate for a visual rendering bug and consistent with other Slider tests.
Selected Fix: PR #30089 — Gates pass, alternative exploration exhausted, PR is the strongest implementation.
…umTrackColor (#30089) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Root Cause of the issue - On Windows, in the default slider style, the [SliderTrackFill](https://github.com/microsoft/microsoft-ui-xaml/blob/main/src/controls/dev/CommonStyles/Slider_themeresources.xaml) resource is mapped to the slider’s background and is used to render the maximum (unfilled) portion of the track. In the normal visual state, the slider background remains unchanged and uses the default style. When a background color is applied via the Slider.Background property, it occupies the same visual area used to render the maximum track. - As a result, when both MaximumTrackColor and Background are set, the background color takes precedence in the normal state, effectively hiding the MaximumTrackColor. Since no visual state override exists for the background in the default template, the assigned background remains active and visually overrides the maximum track. - However, during interaction states like PointerOver or Pressed, WinUI applies the MaximumTrackColor to the HorizontalTrackRect, making it appear only on hover or press. - The core issue is that the background color was applied using the Slider.Background property instead of updating the appropriate SliderContainerBackground resource. On Windows, this resource controls the background of the slider’s container and is the correct way to apply background without interfering with maximum track rendering. ### Description of Change - Implemented a mapper for the Slider background color on Windows that updates the SliderContainerBackground and related theme resources. This ensures the background is applied to the slider's root layout, consistent with other platforms. As a result, both Background and MaximumTrackColor now render correctly without overlapping, resolving the issue. This approach ensures visual consistency with how the slider appears on other platforms. ### Issues Fixed Fixes #25921 ### Tested the behaviour in the following platforms - [x] Windows - [x] iOS - [x] Mac - [x] Android ### Screenshot **Note:** In this video, the `BackgroundColor` is set to `yellow`, and the `MaximumTrackColor` is set to `red`. | Before Fix | After Fix | |----------|----------| | <video src="https://github.com/user-attachments/assets/815d6e24-94f4-42ec-8e68-2abbcd0f0ba5"> | <video src="https://github.com/user-attachments/assets/9f4d5847-5db1-4b8c-9dc9-1efffa95fc27"> |
…sample on candidate (#34697) ### Details PR #30538 fixes the Windows Switch control width issue, where it previously reserved unnecessary space inherited from WinUI’s ToggleSwitch default style. Due to this change, we need to re-save the existing switch images. Also the reduced Switch width, the grid columns in AppThemePage are rebalanced, causing the RadioButton (which has Grid.ColumnSpan="2") to overlap the Editor control on the right side. ### Description of Change: - Before: RadioButton had Grid.ColumnSpan="2", causing it to span both columns and overlap the Editor in Column 1 of the same row. - After: RadioButton is constrained to Grid.Column="0" only, so the Editor in Column 1 remains in its own cell without overlap. ### Failures caused by these PRs: #30538 - The Switch previously occupied the full width; now it takes only the required space. #30089 - The Slider previously appeared without a background color, now the background color is applied correctly. ### Screenshots | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="300" height="600" src="https://github.com/user-attachments/assets/ac70ad29-f055-4870-b9b2-5a381f601254"> | <img width="300" height="600" src="https://github.com/user-attachments/assets/a06482bf-c0de-4c27-87be-d9d00a503723"> |
…umTrackColor (dotnet#30089) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Root Cause of the issue - On Windows, in the default slider style, the [SliderTrackFill](https://github.com/microsoft/microsoft-ui-xaml/blob/main/src/controls/dev/CommonStyles/Slider_themeresources.xaml) resource is mapped to the slider’s background and is used to render the maximum (unfilled) portion of the track. In the normal visual state, the slider background remains unchanged and uses the default style. When a background color is applied via the Slider.Background property, it occupies the same visual area used to render the maximum track. - As a result, when both MaximumTrackColor and Background are set, the background color takes precedence in the normal state, effectively hiding the MaximumTrackColor. Since no visual state override exists for the background in the default template, the assigned background remains active and visually overrides the maximum track. - However, during interaction states like PointerOver or Pressed, WinUI applies the MaximumTrackColor to the HorizontalTrackRect, making it appear only on hover or press. - The core issue is that the background color was applied using the Slider.Background property instead of updating the appropriate SliderContainerBackground resource. On Windows, this resource controls the background of the slider’s container and is the correct way to apply background without interfering with maximum track rendering. ### Description of Change - Implemented a mapper for the Slider background color on Windows that updates the SliderContainerBackground and related theme resources. This ensures the background is applied to the slider's root layout, consistent with other platforms. As a result, both Background and MaximumTrackColor now render correctly without overlapping, resolving the issue. This approach ensures visual consistency with how the slider appears on other platforms. ### Issues Fixed Fixes dotnet#25921 ### Tested the behaviour in the following platforms - [x] Windows - [x] iOS - [x] Mac - [x] Android ### Screenshot **Note:** In this video, the `BackgroundColor` is set to `yellow`, and the `MaximumTrackColor` is set to `red`. | Before Fix | After Fix | |----------|----------| | <video src="https://github.com/user-attachments/assets/815d6e24-94f4-42ec-8e68-2abbcd0f0ba5"> | <video src="https://github.com/user-attachments/assets/9f4d5847-5db1-4b8c-9dc9-1efffa95fc27"> |
…umTrackColor (#30089) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Root Cause of the issue - On Windows, in the default slider style, the [SliderTrackFill](https://github.com/microsoft/microsoft-ui-xaml/blob/main/src/controls/dev/CommonStyles/Slider_themeresources.xaml) resource is mapped to the slider’s background and is used to render the maximum (unfilled) portion of the track. In the normal visual state, the slider background remains unchanged and uses the default style. When a background color is applied via the Slider.Background property, it occupies the same visual area used to render the maximum track. - As a result, when both MaximumTrackColor and Background are set, the background color takes precedence in the normal state, effectively hiding the MaximumTrackColor. Since no visual state override exists for the background in the default template, the assigned background remains active and visually overrides the maximum track. - However, during interaction states like PointerOver or Pressed, WinUI applies the MaximumTrackColor to the HorizontalTrackRect, making it appear only on hover or press. - The core issue is that the background color was applied using the Slider.Background property instead of updating the appropriate SliderContainerBackground resource. On Windows, this resource controls the background of the slider’s container and is the correct way to apply background without interfering with maximum track rendering. ### Description of Change - Implemented a mapper for the Slider background color on Windows that updates the SliderContainerBackground and related theme resources. This ensures the background is applied to the slider's root layout, consistent with other platforms. As a result, both Background and MaximumTrackColor now render correctly without overlapping, resolving the issue. This approach ensures visual consistency with how the slider appears on other platforms. ### Issues Fixed Fixes #25921 ### Tested the behaviour in the following platforms - [x] Windows - [x] iOS - [x] Mac - [x] Android ### Screenshot **Note:** In this video, the `BackgroundColor` is set to `yellow`, and the `MaximumTrackColor` is set to `red`. | Before Fix | After Fix | |----------|----------| | <video src="https://github.com/user-attachments/assets/815d6e24-94f4-42ec-8e68-2abbcd0f0ba5"> | <video src="https://github.com/user-attachments/assets/9f4d5847-5db1-4b8c-9dc9-1efffa95fc27"> |
…sample on candidate (#34697) ### Details PR #30538 fixes the Windows Switch control width issue, where it previously reserved unnecessary space inherited from WinUI’s ToggleSwitch default style. Due to this change, we need to re-save the existing switch images. Also the reduced Switch width, the grid columns in AppThemePage are rebalanced, causing the RadioButton (which has Grid.ColumnSpan="2") to overlap the Editor control on the right side. ### Description of Change: - Before: RadioButton had Grid.ColumnSpan="2", causing it to span both columns and overlap the Editor in Column 1 of the same row. - After: RadioButton is constrained to Grid.Column="0" only, so the Editor in Column 1 remains in its own cell without overlap. ### Failures caused by these PRs: #30538 - The Switch previously occupied the full width; now it takes only the required space. #30089 - The Slider previously appeared without a background color, now the background color is applied correctly. ### Screenshots | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="300" height="600" src="https://github.com/user-attachments/assets/ac70ad29-f055-4870-b9b2-5a381f601254"> | <img width="300" height="600" src="https://github.com/user-attachments/assets/a06482bf-c0de-4c27-87be-d9d00a503723"> |
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Root Cause of the issue
On Windows, in the default slider style, the SliderTrackFill resource is mapped to the slider’s background and is used to render the maximum (unfilled) portion of the track. In the normal visual state, the slider background remains unchanged and uses the default style. When a background color is applied via the Slider.Background property, it occupies the same visual area used to render the maximum track.
As a result, when both MaximumTrackColor and Background are set, the background color takes precedence in the normal state, effectively hiding the MaximumTrackColor. Since no visual state override exists for the background in the default template, the assigned background remains active and visually overrides the maximum track.
However, during interaction states like PointerOver or Pressed, WinUI applies the MaximumTrackColor to the HorizontalTrackRect, making it appear only on hover or press.
The core issue is that the background color was applied using the Slider.Background property instead of updating the appropriate SliderContainerBackground resource. On Windows, this resource controls the background of the slider’s container and is the correct way to apply background without interfering with maximum track rendering.
Description of Change
Issues Fixed
Fixes #25921
Tested the behaviour in the following platforms
Screenshot
Note: In this video, the
BackgroundColoris set toyellow, and theMaximumTrackColoris set tored.Before-Fix-Windows.mp4
After-Fix-Windows.mp4