Skip to content

[Windows] Fixed: Setting BackgroundColor for Slider updates the MaximumTrackColor#30089

Merged
kubaflo merged 7 commits intodotnet:inflight/currentfrom
Tamilarasan-Paranthaman:fix-25921
Mar 21, 2026
Merged

[Windows] Fixed: Setting BackgroundColor for Slider updates the MaximumTrackColor#30089
kubaflo merged 7 commits intodotnet:inflight/currentfrom
Tamilarasan-Paranthaman:fix-25921

Conversation

@Tamilarasan-Paranthaman
Copy link
Copy Markdown
Member

@Tamilarasan-Paranthaman Tamilarasan-Paranthaman commented Jun 20, 2025

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

  • 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

  • Windows
  • iOS
  • Mac
  • Android

Screenshot

Note: In this video, the BackgroundColor is set to yellow, and the MaximumTrackColor is set to red.

Before Fix After Fix
Before-Fix-Windows.mp4
After-Fix-Windows.mp4

@dotnet-policy-service dotnet-policy-service bot added community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration labels Jun 20, 2025
@jsuarezruiz
Copy link
Copy Markdown
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@Tamilarasan-Paranthaman Tamilarasan-Paranthaman marked this pull request as ready for review June 20, 2025 14:13
Copilot AI review requested due to automatic review settings June 20, 2025 14:13
@Tamilarasan-Paranthaman Tamilarasan-Paranthaman requested a review from a team as a code owner June 20, 2025 14:13
Copy link
Copy Markdown
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 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.

@jsuarezruiz
Copy link
Copy Markdown
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@jsuarezruiz
Copy link
Copy Markdown
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@jsuarezruiz
Copy link
Copy Markdown
Contributor

/rebase

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 9, 2025

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 30089

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 30089"

@MauiBot
Copy link
Copy Markdown
Collaborator

MauiBot commented Mar 21, 2026

🤖 AI Summary

📊 Expand Full Review551ba44 · Added updated snapshots
🔍 Pre-Flight — Context & Validation

Issue: #25921 - [Windows] Setting BackgroundColor for Slider updates the Maximum Track Color
PR: #30089 - [Windows] Fixed: Setting BackgroundColor for Slider updates the MaximumTrackColor
Platforms Affected: Windows
Files Changed: 3 implementation, 3 test source, 15 snapshot

Key Findings

  • The linked issue is Windows-specific: setting Slider.BackgroundColor also changes the maximum track rendering even when MaximumTrackColor is explicitly set.
  • Issue discussion points to the WinUI limitation/root behavior: both background and maximum track color end up mapped through the same underlying slider background path, creating the visual conflict.
  • The PR addresses review feedback by expanding the HostApp repro page to include a second slider plus a button that updates background dynamically.
  • Changed implementation is limited to Windows slider handling: a Windows-only background mapper is added, and SliderExtensions centralizes color resource updates via a shared helper.
  • Test coverage includes a new issue page and UITest (Issue25921) plus Windows snapshot refreshes; cross-platform snapshot additions appear intended to keep baseline assets aligned.
  • No prior phase-based agent review was found in PR comments; only standard bot review output and human review feedback were present.

Fix Candidates

# 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.BackgroundColor visually overrides MaximumTrackColor because the default WinUI slider template uses the control's Background property path for rendering the unfilled track (SliderTrackFill resources). When Background is set it occupies the same visual layer as the maximum track color.
  • During PointerOver/Pressed states WinUI correctly applies MaximumTrackColor to HorizontalTrackRect, 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 the SliderContainerBackground* theme resources instead of letting the background propagate through the generic View.Background path.
  • SliderExtensions.cs refactored: extracted a shared UpdateColor helper, eliminating per-method repetition across UpdateMinimumTrackColor, UpdateMaximumTrackColor, UpdateThumbColor, and new UpdateBackgroundColor.
  • Bugzilla29128.cs had a #if TEST_FAILS_ON_WINDOWS guard 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 (not BackgroundColor) 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

  • MapBackgroundColor is placed inside a #if WINDOWS block in the cross-platform SliderHandler.cs Mapper dictionary, which is the established pattern when a mapper entry is purely platform-specific.
  • MapBackgroundColor is internal in SliderHandler.Windows.cs (other map methods are public) — intentional since this is a Windows-only internal implementation detail, not part of the shared public surface.
  • Both BackgroundColor and Background on the MAUI View ultimately flow through the IView.Background property to the mapper, so the single mapper key covers both cases.
  • The UpdateColor helper accepts a Slider base type, and UpdateBackgroundColor accepts MauiSlider (which extends Slider), 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 Background property to the same visual channel used to render the unfilled (maximum) track (SliderTrackFill resources). When Slider.Background is set via MAUI's generic ViewMapper, it occupies that visual slot and overrides MaximumTrackColor in the Normal state. The MaximumTrackColor only appears on PointerOver/Pressed states because those states explicitly apply it to HorizontalTrackRect.
  • Fix approach: Adds a Windows-only Background mapper entry (MapBackgroundColor) that routes background updates to SliderContainerBackground* theme resources instead of the visual override path.
  • Refactor: Extracted shared UpdateColor(Slider, string[], Brush?) helper, eliminating duplicated code across UpdateMinimumTrackColor, UpdateMaximumTrackColor, and UpdateThumbColor.
  • Test guard removal: Bugzilla29128.cs had a #if TEST_FAILS_ON_WINDOWS guard 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 (not BackgroundColor) 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

  • MapBackgroundColor is placed inside a #if WINDOWS block in cross-platform SliderHandler.cs — established MAUI pattern for platform-specific mapper entries.
  • MapBackgroundColor is declared internal in SliderHandler.Windows.cs while all other map methods are public. This is a potential concern: it cannot be overridden from user-code custom mappers that reference the method by name.
  • Both BackgroundColor and Background on the MAUI View flow through IView.Background to the mapper, so the single mapper key covers both cases.
  • UpdateBackgroundColor accepts MauiSlider (which extends Slider), consistent with UpdateThumbImageSourceAsync.
  • BackgroundColorResourceKeys array 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.cs
  • src/Core/src/Handlers/Slider/SliderHandler.Windows.cs
  • src/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.cs
  • src/Core/src/Handlers/Slider/SliderHandler.Windows.cs
  • src/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.cs
  • src/Core/src/Handlers/Slider/SliderHandler.Windows.cs
  • src/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:

  1. 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)
  2. Simplest and most explicit: Mapper entry pattern is well-established in MAUI; immediately discoverable
  3. Consistent: Follows same pattern as MinimumTrackColor, MaximumTrackColor, ThumbColor handlers
  4. Bonus refactor: The shared UpdateColor helper eliminates duplicated code across 3 methods
  5. 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 ⚠️ SKIPPED 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 WINDOWS mapper entry in the cross-platform SliderHandler.cs — consistent with the project's pattern for platform-specific mapper overrides.
  • Adds an internal MapBackgroundColor method in SliderHandler.Windows.cs that delegates to MauiSlider.UpdateBackgroundColor() — correct access level for a Windows-only, non-public concern.
  • Refactors SliderExtensions.cs to extract a shared UpdateColor(Slider, string[], Brush?) helper, removing 3× duplicated code blocks from UpdateMinimumTrackColor, UpdateMaximumTrackColor, and UpdateThumbColor.
  • Covers all four visual states (Normal, PointerOver, Pressed, Disabled) for SliderContainerBackground.
  • The HostApp page tests both BackgroundColor (Yellow) and Background (Grey → Salmon via button) on separate sliders, providing good dynamic coverage.
  • The Bugzilla29128 test guard removal is correct — that test was disabled on Windows specifically because of this bug.

Potential Concerns (Minor)

  1. #if WINDOWS in 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 a partial class override, but the current approach matches existing MAUI patterns and is acceptable.
  2. No BackgroundColor null reset path explicitly tested: The HostApp page does not test what happens when BackgroundColor is reset to null/Colors.Default after being set. However, the UpdateColor helper correctly calls RemoveKeys when brush is null, so the path exists.
  3. Snapshot-only test coverage: VerifySliderColors relies 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 WINDOWS mapper entry [nameof(ISlider.Background)] = MapBackgroundColor in cross-platform SliderHandler.cs — the established MAUI pattern for platform-specific mapper overrides (consistent with other patterns in the codebase)
  • Adds MapBackgroundColor in SliderHandler.Windows.cs delegating to mauiSlider.UpdateBackgroundColor() — correct separation of mapper dispatch from platform logic
  • Adds UpdateBackgroundColor/UpdateColor shared helper in SliderExtensions.cs routing background to SliderContainerBackground* resources — covers all 4 visual states (Normal, PointerOver, Pressed, Disabled) and handles null reset via RemoveKeys
  • Removes the #if TEST_FAILS_ON_WINDOWS guard from Bugzilla29128.cs — correct, since this guard existed specifically because of this bug
  • HostApp page tests both BackgroundColor (Yellow, static) and Background (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)

  1. MapBackgroundColor is internal while other map methods are public: All other mapper methods (MapMinimumTrackColor, MapThumbColor, etc.) in SliderHandler.Windows.cs are public static. Making MapBackgroundColor internal means 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.
  2. No unit test for null reset path: The HostApp page doesn't test resetting BackgroundColor back to null/Colors.Default after setting it. The code path exists (RemoveKeys when brush is null) but has no test coverage. Low risk given the shared UpdateColor helper is used for all other colors.
  3. Snapshot-only test coverage: VerifySliderColors relies 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.


@MauiBot MauiBot added s/agent-approved AI agent recommends approval - PR fix is correct and optimal s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) labels Mar 21, 2026
@kubaflo kubaflo changed the base branch from main to inflight/current March 21, 2026 23:34
@kubaflo kubaflo merged commit 544858c into dotnet:inflight/current Mar 21, 2026
122 of 186 checks passed
PureWeen pushed a commit that referenced this pull request Mar 24, 2026
…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">
|
kubaflo pushed a commit that referenced this pull request Mar 27, 2026
…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">
|
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Mar 30, 2026
…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">
|
sheiksyedm pushed a commit that referenced this pull request Apr 4, 2026
…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">
|
sheiksyedm pushed a commit that referenced this pull request Apr 4, 2026
…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">
|
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-slider Slider community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/windows s/agent-approved AI agent recommends approval - PR fix is correct and optimal s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Windows] Setting BackgroundColor for Slider updates the Maximum Track Color

8 participants