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 300072f2d166..a77acdd25d51 100644 --- a/src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt @@ -150,6 +150,9 @@ static readonly Microsoft.Maui.Controls.TitleBar.TitleProperty -> Microsoft.Maui 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 +~static readonly Microsoft.Maui.Controls.Switch.OffColorProperty -> Microsoft.Maui.Controls.BindableProperty +~Microsoft.Maui.Controls.Switch.OffColor.get -> Microsoft.Maui.Graphics.Color +~Microsoft.Maui.Controls.Switch.OffColor.set -> void ~Microsoft.Maui.Controls.SearchBar.SearchIconColor.get -> Microsoft.Maui.Graphics.Color ~Microsoft.Maui.Controls.SearchBar.SearchIconColor.set -> void ~static readonly Microsoft.Maui.Controls.SearchBar.SearchIconColorProperty -> Microsoft.Maui.Controls.BindableProperty 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 bd5f4d9c6fe0..df5ca4aecc69 100644 --- a/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt @@ -341,6 +341,9 @@ virtual Microsoft.Maui.Controls.Handlers.Items2.ItemsViewController2 virtual Microsoft.Maui.Controls.Handlers.Items2.ItemsViewDelegator2.GetVisibleItemsIndex() -> (bool VisibleItems, int First, int Center, int Last) virtual Microsoft.Maui.Controls.Handlers.Items2.ItemsViewHandler2.UpdateLayout() -> void override Microsoft.Maui.Controls.Handlers.Compatibility.FrameRenderer.MovedToWindow() -> void +~static readonly Microsoft.Maui.Controls.Switch.OffColorProperty -> Microsoft.Maui.Controls.BindableProperty +~Microsoft.Maui.Controls.Switch.OffColor.get -> Microsoft.Maui.Graphics.Color +~Microsoft.Maui.Controls.Switch.OffColor.set -> void ~Microsoft.Maui.Controls.SearchBar.SearchIconColor.get -> Microsoft.Maui.Graphics.Color ~Microsoft.Maui.Controls.SearchBar.SearchIconColor.set -> void ~static readonly Microsoft.Maui.Controls.SearchBar.SearchIconColorProperty -> Microsoft.Maui.Controls.BindableProperty 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 834d07911fd4..6faeaf8e0c18 100644 --- a/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt @@ -342,6 +342,9 @@ virtual Microsoft.Maui.Controls.Handlers.Items2.ItemsViewController2 virtual Microsoft.Maui.Controls.Handlers.Items2.ItemsViewDelegator2.GetVisibleItemsIndex() -> (bool VisibleItems, int First, int Center, int Last) virtual Microsoft.Maui.Controls.Handlers.Items2.ItemsViewHandler2.UpdateLayout() -> void override Microsoft.Maui.Controls.Handlers.Compatibility.FrameRenderer.MovedToWindow() -> void +~static readonly Microsoft.Maui.Controls.Switch.OffColorProperty -> Microsoft.Maui.Controls.BindableProperty +~Microsoft.Maui.Controls.Switch.OffColor.get -> Microsoft.Maui.Graphics.Color +~Microsoft.Maui.Controls.Switch.OffColor.set -> void ~Microsoft.Maui.Controls.SearchBar.SearchIconColor.get -> Microsoft.Maui.Graphics.Color ~Microsoft.Maui.Controls.SearchBar.SearchIconColor.set -> void ~static readonly Microsoft.Maui.Controls.SearchBar.SearchIconColorProperty -> Microsoft.Maui.Controls.BindableProperty 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 6271ddb60890..b2e6e823ba53 100644 --- a/src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt @@ -143,6 +143,9 @@ static readonly Microsoft.Maui.Controls.TitleBar.TitleProperty -> Microsoft.Maui 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 +~static readonly Microsoft.Maui.Controls.Switch.OffColorProperty -> Microsoft.Maui.Controls.BindableProperty +~Microsoft.Maui.Controls.Switch.OffColor.get -> Microsoft.Maui.Graphics.Color +~Microsoft.Maui.Controls.Switch.OffColor.set -> void ~Microsoft.Maui.Controls.SearchBar.SearchIconColor.get -> Microsoft.Maui.Graphics.Color ~Microsoft.Maui.Controls.SearchBar.SearchIconColor.set -> void ~static readonly Microsoft.Maui.Controls.SearchBar.SearchIconColorProperty -> Microsoft.Maui.Controls.BindableProperty 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 d45c590f2ab2..0970d89174f5 100644 --- a/src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt @@ -149,6 +149,9 @@ static readonly Microsoft.Maui.Controls.TitleBar.TitleProperty -> Microsoft.Maui 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 +~static readonly Microsoft.Maui.Controls.Switch.OffColorProperty -> Microsoft.Maui.Controls.BindableProperty +~Microsoft.Maui.Controls.Switch.OffColor.get -> Microsoft.Maui.Graphics.Color +~Microsoft.Maui.Controls.Switch.OffColor.set -> void ~Microsoft.Maui.Controls.SearchBar.SearchIconColor.get -> Microsoft.Maui.Graphics.Color ~Microsoft.Maui.Controls.SearchBar.SearchIconColor.set -> void ~static readonly Microsoft.Maui.Controls.SearchBar.SearchIconColorProperty -> Microsoft.Maui.Controls.BindableProperty diff --git a/src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt index 8a752b366bca..50f094b47789 100644 --- a/src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt @@ -143,6 +143,9 @@ static readonly Microsoft.Maui.Controls.TitleBar.TitleProperty -> Microsoft.Maui 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 +~static readonly Microsoft.Maui.Controls.Switch.OffColorProperty -> Microsoft.Maui.Controls.BindableProperty +~Microsoft.Maui.Controls.Switch.OffColor.get -> Microsoft.Maui.Graphics.Color +~Microsoft.Maui.Controls.Switch.OffColor.set -> void ~Microsoft.Maui.Controls.SearchBar.SearchIconColor.get -> Microsoft.Maui.Graphics.Color ~Microsoft.Maui.Controls.SearchBar.SearchIconColor.set -> void ~static readonly Microsoft.Maui.Controls.SearchBar.SearchIconColorProperty -> Microsoft.Maui.Controls.BindableProperty diff --git a/src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt b/src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt index 6271ddb60890..b2e6e823ba53 100644 --- a/src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt +++ b/src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt @@ -143,6 +143,9 @@ static readonly Microsoft.Maui.Controls.TitleBar.TitleProperty -> Microsoft.Maui 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 +~static readonly Microsoft.Maui.Controls.Switch.OffColorProperty -> Microsoft.Maui.Controls.BindableProperty +~Microsoft.Maui.Controls.Switch.OffColor.get -> Microsoft.Maui.Graphics.Color +~Microsoft.Maui.Controls.Switch.OffColor.set -> void ~Microsoft.Maui.Controls.SearchBar.SearchIconColor.get -> Microsoft.Maui.Graphics.Color ~Microsoft.Maui.Controls.SearchBar.SearchIconColor.set -> void ~static readonly Microsoft.Maui.Controls.SearchBar.SearchIconColorProperty -> Microsoft.Maui.Controls.BindableProperty diff --git a/src/Controls/src/Core/Switch/Switch.cs b/src/Controls/src/Core/Switch/Switch.cs index b0dbafccfabb..d47333eb731d 100644 --- a/src/Controls/src/Core/Switch/Switch.cs +++ b/src/Controls/src/Core/Switch/Switch.cs @@ -31,6 +31,13 @@ public partial class Switch : View, IElementConfiguration, ISwitch ((IView)bindable)?.Handler?.UpdateValue(nameof(ISwitch.TrackColor)); }); + /// Bindable property for . + public static readonly BindableProperty OffColorProperty = BindableProperty.Create(nameof(OffColor), typeof(Color), typeof(Switch), null, + propertyChanged: (bindable, oldValue, newValue) => + { + ((IView)bindable)?.Handler?.UpdateValue(nameof(ISwitch.TrackColor)); + }); + /// Bindable property for . public static readonly BindableProperty ThumbColorProperty = BindableProperty.Create(nameof(ThumbColor), typeof(Color), typeof(Switch), null); @@ -41,6 +48,17 @@ public Color OnColor set { SetValue(OnColorProperty, value); } } + /// + /// Gets or sets the color of the toggle switch's track when it is in the off state. + /// If not set, the default color will be used for the off-track appearance. + /// + public Color OffColor + { + get { return (Color) GetValue(OffColorProperty); } + set { SetValue(OffColorProperty, value); } + } + + /// public Color ThumbColor { @@ -93,14 +111,14 @@ Color ISwitch.TrackColor { get { -#if WINDOWS - return OnColor; -#else if (IsToggled) + { return OnColor; - - return null; -#endif + } + else + { + return OffColor; + } } } diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/VerifySwitchNullColor.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/VerifySwitchNullColor.png new file mode 100644 index 000000000000..075a984eb431 Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/VerifySwitchNullColor.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/VerifySwitchOffColorAfterToggling.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/VerifySwitchOffColorAfterToggling.png new file mode 100644 index 000000000000..159f152710f4 Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/VerifySwitchOffColorAfterToggling.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/VerifySwitchOffColorAfterTogglingDarkTheme.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/VerifySwitchOffColorAfterTogglingDarkTheme.png new file mode 100644 index 000000000000..155018e7c3e2 Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/VerifySwitchOffColorAfterTogglingDarkTheme.png differ diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue15695.xaml b/src/Controls/tests/TestCases.HostApp/Issues/Issue15695.xaml new file mode 100644 index 000000000000..906bdfb41d70 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue15695.xaml @@ -0,0 +1,30 @@ + + + + + +