diff --git a/src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt index 5b8f9021d63e..5ce5a638eaf6 100644 --- a/src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt @@ -148,4 +148,5 @@ static readonly Microsoft.Maui.Controls.TitleBar.SubtitleProperty -> Microsoft.M static readonly Microsoft.Maui.Controls.TitleBar.TitleProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.TitleBar.TrailingContentProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Window.TitleBarProperty -> Microsoft.Maui.Controls.BindableProperty! -virtual Microsoft.Maui.Controls.Application.ActivateWindow(Microsoft.Maui.Controls.Window! window) -> void \ No newline at end of file +virtual Microsoft.Maui.Controls.Application.ActivateWindow(Microsoft.Maui.Controls.Window! window) -> void +~override Microsoft.Maui.Controls.RadioButton.OnPropertyChanged(string propertyName = null) -> void \ No newline at end of file diff --git a/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt index e33dcb76f5a2..15bf66ceecd3 100644 --- a/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt @@ -348,3 +348,4 @@ virtual Microsoft.Maui.Controls.Handlers.Items2.ItemsViewHandler2.Up *REMOVED*override Microsoft.Maui.Controls.Handlers.Compatibility.FrameRenderer.SetNeedsLayout() -> void *REMOVED*override Microsoft.Maui.Controls.Handlers.Compatibility.FrameRenderer.MovedToWindow() -> void override Microsoft.Maui.Controls.Handlers.Compatibility.VisualElementRenderer.MovedToWindow() -> void +~override Microsoft.Maui.Controls.RadioButton.OnPropertyChanged(string propertyName = null) -> void diff --git a/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt index 6950a4815676..090d9257b433 100644 --- a/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt @@ -347,4 +347,5 @@ virtual Microsoft.Maui.Controls.Handlers.Items2.ItemsViewDelegator2.UpdateLayout() -> void *REMOVED*override Microsoft.Maui.Controls.Handlers.Compatibility.FrameRenderer.SetNeedsLayout() -> void *REMOVED*override Microsoft.Maui.Controls.Handlers.Compatibility.FrameRenderer.MovedToWindow() -> void -override Microsoft.Maui.Controls.Handlers.Compatibility.VisualElementRenderer.MovedToWindow() -> void \ No newline at end of file +override Microsoft.Maui.Controls.Handlers.Compatibility.VisualElementRenderer.MovedToWindow() -> void +~override Microsoft.Maui.Controls.RadioButton.OnPropertyChanged(string propertyName = null) -> void \ No newline at end of file diff --git a/src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt index 4ee051439ef7..03af9e1ac5ac 100644 --- a/src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt @@ -143,4 +143,5 @@ static readonly Microsoft.Maui.Controls.TitleBar.SubtitleProperty -> Microsoft.M static readonly Microsoft.Maui.Controls.TitleBar.TitleProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.TitleBar.TrailingContentProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Window.TitleBarProperty -> Microsoft.Maui.Controls.BindableProperty! -virtual Microsoft.Maui.Controls.Application.ActivateWindow(Microsoft.Maui.Controls.Window! window) -> void \ No newline at end of file +virtual Microsoft.Maui.Controls.Application.ActivateWindow(Microsoft.Maui.Controls.Window! window) -> void +~override Microsoft.Maui.Controls.RadioButton.OnPropertyChanged(string propertyName = null) -> void \ No newline at end of file diff --git a/src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt index c2190ccab4e5..e04d727e7bb2 100644 --- a/src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt @@ -149,4 +149,5 @@ static readonly Microsoft.Maui.Controls.TitleBar.SubtitleProperty -> Microsoft.M static readonly Microsoft.Maui.Controls.TitleBar.TitleProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.TitleBar.TrailingContentProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Window.TitleBarProperty -> Microsoft.Maui.Controls.BindableProperty! -virtual Microsoft.Maui.Controls.Application.ActivateWindow(Microsoft.Maui.Controls.Window! window) -> void \ No newline at end of file +virtual Microsoft.Maui.Controls.Application.ActivateWindow(Microsoft.Maui.Controls.Window! window) -> void +~override Microsoft.Maui.Controls.RadioButton.OnPropertyChanged(string propertyName = null) -> void \ No newline at end of file diff --git a/src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt index 0950e21053b6..7b9895e97515 100644 --- a/src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt @@ -143,4 +143,5 @@ static readonly Microsoft.Maui.Controls.TitleBar.SubtitleProperty -> Microsoft.M static readonly Microsoft.Maui.Controls.TitleBar.TitleProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.TitleBar.TrailingContentProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Window.TitleBarProperty -> Microsoft.Maui.Controls.BindableProperty! -virtual Microsoft.Maui.Controls.Application.ActivateWindow(Microsoft.Maui.Controls.Window! window) -> void \ No newline at end of file +virtual Microsoft.Maui.Controls.Application.ActivateWindow(Microsoft.Maui.Controls.Window! window) -> void +~override Microsoft.Maui.Controls.RadioButton.OnPropertyChanged(string propertyName = null) -> void \ No newline at end of file diff --git a/src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt index 4ee051439ef7..03af9e1ac5ac 100644 --- a/src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt @@ -143,4 +143,5 @@ static readonly Microsoft.Maui.Controls.TitleBar.SubtitleProperty -> Microsoft.M static readonly Microsoft.Maui.Controls.TitleBar.TitleProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.TitleBar.TrailingContentProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Window.TitleBarProperty -> Microsoft.Maui.Controls.BindableProperty! -virtual Microsoft.Maui.Controls.Application.ActivateWindow(Microsoft.Maui.Controls.Window! window) -> void \ No newline at end of file +virtual Microsoft.Maui.Controls.Application.ActivateWindow(Microsoft.Maui.Controls.Window! window) -> void +~override Microsoft.Maui.Controls.RadioButton.OnPropertyChanged(string propertyName = null) -> void \ No newline at end of file diff --git a/src/Controls/src/Core/RadioButton/RadioButton.cs b/src/Controls/src/Core/RadioButton/RadioButton.cs index 6a40dedf8119..ba5c1ca7ff84 100644 --- a/src/Controls/src/Core/RadioButton/RadioButton.cs +++ b/src/Controls/src/Core/RadioButton/RadioButton.cs @@ -1,6 +1,7 @@ #nullable disable using System; using System.Diagnostics; +using System.Runtime.CompilerServices; using Microsoft.Extensions.Logging; using Microsoft.Maui.Controls.Internals; using Microsoft.Maui.Controls.Shapes; @@ -279,6 +280,19 @@ void IBorderElement.OnBorderColorPropertyChanged(Color oldValue, Color newValue) { } + protected override void OnPropertyChanged([CallerMemberName] string propertyName = null) + { + base.OnPropertyChanged(propertyName); + if (propertyName == BorderColorProperty.PropertyName) + { + Handler?.UpdateValue(nameof(IRadioButton.StrokeColor)); + } + else if (propertyName == BorderWidthProperty.PropertyName) + { + Handler?.UpdateValue(nameof(IRadioButton.StrokeThickness)); + } + } + bool IBorderElement.IsCornerRadiusSet() => IsSet(BorderElement.CornerRadiusProperty); bool IBorderElement.IsBackgroundColorSet() => IsSet(BackgroundColorProperty); bool IBorderElement.IsBackgroundSet() => IsSet(BackgroundProperty); @@ -638,7 +652,7 @@ public string ContentAsString() Font ITextStyle.Font => this.ToFont(); #if ANDROID - object IContentView.Content + object IContentView.Content { get { diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/ValidateRadioButtonBorderColor.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/ValidateRadioButtonBorderColor.png new file mode 100644 index 000000000000..9dd039d20e92 Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/ValidateRadioButtonBorderColor.png differ diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue15806.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue15806.cs new file mode 100644 index 000000000000..f40ae860aef5 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue15806.cs @@ -0,0 +1,70 @@ +namespace Controls.TestCases.HostApp.Issues; + +[Issue(IssueTracker.Github, 15806, "RadioButton Border color not working for focused visual state", PlatformAffected.All)] +class Issue15806 : ContentPage +{ + public Issue15806() + { + VerticalStackLayout verticalStackLayout = new VerticalStackLayout(); + + Style radioButtonStyle = new Style(typeof(RadioButton)) + { + Setters = + { + new Setter + { + Property = VisualStateManager.VisualStateGroupsProperty, + Value = new VisualStateGroupList + { + 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 } + } + } + } + } + } + } + } + }; + + RadioButton focusedRadioButton = new RadioButton + { + AutomationId = "FocusedRadioButton", + Content = "RadioButton", + Style = radioButtonStyle, + IsChecked = true, + }; + + RadioButton normalRadioButton = new RadioButton + { + AutomationId = "NormalRadioButton", + Content = "RadioButton", + Style = radioButtonStyle, + }; + + verticalStackLayout.Children.Add(focusedRadioButton); + verticalStackLayout.Children.Add(normalRadioButton); + + Content = verticalStackLayout; + } +} diff --git a/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/ValidateRadioButtonBorderColor.png b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/ValidateRadioButtonBorderColor.png new file mode 100644 index 000000000000..affa938c4654 Binary files /dev/null and b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/ValidateRadioButtonBorderColor.png differ diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue15806.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue15806.cs new file mode 100644 index 000000000000..e91e19d73258 --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue15806.cs @@ -0,0 +1,22 @@ +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests.Issues; + +internal class Issue15806 : _IssuesUITest +{ + public Issue15806(TestDevice device) : base(device) { } + + public override string Issue => "RadioButton Border color not working for focused visual state"; + + [Test] + [Category(UITestCategories.RadioButton)] + public void ValidateRadioButtonBorderColor() + { + App.WaitForElement("FocusedRadioButton"); + App.Tap("NormalRadioButton"); + VerifyScreenshot(); + } +} + diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/ValidateRadioButtonBorderColor.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/ValidateRadioButtonBorderColor.png new file mode 100644 index 000000000000..6fb66d1d593c Binary files /dev/null and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/ValidateRadioButtonBorderColor.png differ diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/ValidateRadioButtonBorderColor.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/ValidateRadioButtonBorderColor.png new file mode 100644 index 000000000000..b604ab354bc4 Binary files /dev/null and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/ValidateRadioButtonBorderColor.png differ