[Windows] Fix for RadioButton BorderColor and BorderWidth not updated at runtime#28335
[Windows] Fix for RadioButton BorderColor and BorderWidth not updated at runtime#28335SyedAbdulAzeemSF4852 wants to merge 8 commits intodotnet:mainfrom
Conversation
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
@jsuarezruiz , I have committed the pending snapshots. |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
jsuarezruiz
left a comment
There was a problem hiding this comment.
c7de3f2 to
aef8644
Compare
|
@jsuarezruiz , Previously, on Windows, if the BorderWidth was not explicitly specified, it would default to a Thickness object with a value of 3. As a result, the border would appear visible on Windows even though no border width was set, which could lead to inconsistencies in the UI across different platforms. Later it was fixed in this PR. In addition to setting the BorderColor, I have also included the BorderWidth in the test case to ensure consistent behavior across all platforms. This ensures that the border styling (both color and width) is applied uniformly, making the appearance of the RadioButton consistent regardless of the platform. |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/rebase |
3527aee to
6e71922
Compare
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
I think there are some inconsistencies with how the RadioButton behaves across platforms. In the added sample, the normal and focused states use different colors—Red and DarkCyan, respectively.
- On Android, borders are completely missing, making selection unclear.
- The focus color is applied correctly on Windows, while other platforms do not display it properly.
- Additionally, the RadioButton expands to the full width of its container on most platforms, but Windows does not follow this behavior.
Could you review it? can we align the behavior between platforms?
|
@jsuarezruiz , The issue of RadioButton focus events not firing on iOS and Android has already been mentioned. Issue - 28163. |
6e71922 to
82a61db
Compare
There was a problem hiding this comment.
Pull request overview
This PR implements runtime property change handling for RadioButton's BorderColor and BorderWidth properties on Windows (and all platforms). The issue was that when these properties changed at runtime (e.g., through visual state changes), the RadioButton did not update its visual appearance.
Key changes:
- Added
OnPropertyChangedoverride in RadioButton.cs to propagate BorderColor and BorderWidth changes to the handler - Added UI test to validate the fix
- Generated platform-specific screenshot baselines for the test
Reviewed changes
Copilot reviewed 10 out of 14 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Controls/src/Core/RadioButton/RadioButton.cs | Added OnPropertyChanged override to handle BorderColor and BorderWidth runtime changes, following the Button pattern. Also includes minor whitespace cleanup. |
| src/Controls/tests/TestCases.HostApp/Issues/Issue15806.cs | UI test page that creates RadioButtons with visual state styles to demonstrate border property changes |
| src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue15806.cs | NUnit test implementation that verifies RadioButton border color changes |
| src/Controls/tests/TestCases.*.Tests/snapshots/.../ValidateRadioButtonBorderColor.png | Platform-specific screenshot baselines (Android, iOS, Windows, Mac) for visual verification |
| new VisualStateGroup | ||
| { | ||
| Name = "CheckedStates", | ||
| States = | ||
| { | ||
| new VisualState | ||
| { | ||
| Name = "Normal", | ||
| Setters = | ||
| { | ||
| new Setter { Property = RadioButton.BorderColorProperty, Value = Colors.Red }, | ||
| new Setter { Property = RadioButton.BorderWidthProperty, Value = 2 } | ||
| } | ||
| }, | ||
|
|
||
| new VisualState | ||
| { | ||
| Name = "Focused", | ||
| Setters = | ||
| { | ||
| new Setter { Property = RadioButton.BorderColorProperty, Value = Colors.DarkCyan }, | ||
| new Setter { Property = RadioButton.BorderWidthProperty, Value = 2 } | ||
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
The test uses a custom visual state group "CheckedStates" with "Normal" and "Focused" states. However, the "Focused" visual state should be part of the "Common" visual state group (alongside Normal, Disabled, etc.), not "CheckedStates".
The test appears to conflate "Checked" state (from CheckedStates) with "Focused" state (from Common visual states). When IsChecked = true is set, it triggers the "Checked" visual state, not the "Focused" visual state. This means the test isn't actually validating the runtime border color/width change behavior that the PR claims to fix.
Consider restructuring the test to properly validate the fix:
- Use "Common" visual state group for "Normal" and "Focused" states
- Or explicitly trigger focus change to test the "Focused" visual state
- Or create a test that programmatically changes BorderColor/BorderWidth at runtime to validate the fix directly
…cused visual state ).
…cused visual state ).
…cused visual state ).
…cused visual state ).
…cused visual state )
…cused visual state )
…cused visual state ).
d65f3c0 to
62ff040
Compare




Issue Details
Root Cause
Description of Change
Reference :
maui/src/Controls/src/Core/Button/Button.cs
Line 472 in ac01bde
Validated the behaviour in the following platforms
Issues Fixed
Fixes #15806
Output
RadioButtonBorderColorNotChanged.mp4
RadioButtonBorderColorChanged.mp4