diff --git a/src/Controls/src/Core/CheckBox/CheckBox.cs b/src/Controls/src/Core/CheckBox/CheckBox.cs
index cfc73a6c7d67..b5841f658064 100644
--- a/src/Controls/src/Core/CheckBox/CheckBox.cs
+++ b/src/Controls/src/Core/CheckBox/CheckBox.cs
@@ -1,11 +1,13 @@
#nullable disable
using System;
+using System.Windows.Input;
+using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Graphics;
namespace Microsoft.Maui.Controls
{
///
- public partial class CheckBox : View, IElementConfiguration, IBorderElement, IColorElement, ICheckBox
+ public partial class CheckBox : View, IElementConfiguration, IBorderElement, IColorElement, ICheckBox, ICommandElement
{
readonly Lazy> _platformConfigurationRegistry;
///
@@ -16,11 +18,38 @@ public partial class CheckBox : View, IElementConfiguration, IBorderEl
BindableProperty.Create(nameof(IsChecked), typeof(bool), typeof(CheckBox), false,
propertyChanged: (bindable, oldValue, newValue) =>
{
- ((CheckBox)bindable).Handler?.UpdateValue(nameof(ICheckBox.Foreground));
- ((CheckBox)bindable).CheckedChanged?.Invoke(bindable, new CheckedChangedEventArgs((bool)newValue));
- ((CheckBox)bindable).ChangeVisualState();
+ if (bindable is not CheckBox checkBox)
+ {
+ return;
+ }
+
+ checkBox.Handler?.UpdateValue(nameof(ICheckBox.Foreground));
+ checkBox.CheckedChanged?.Invoke(bindable, new CheckedChangedEventArgs((bool)newValue));
+ if (checkBox.Command is not null && checkBox.Command.CanExecute(checkBox.CommandParameter))
+ {
+ checkBox.Command.Execute(checkBox.CommandParameter);
+ }
+
+ checkBox.ChangeVisualState();
}, defaultBindingMode: BindingMode.TwoWay);
+
+ public static readonly BindableProperty CommandProperty = BindableProperty.Create(nameof(Command), typeof(ICommand), typeof(CheckBox), null, propertyChanging: CommandElement.OnCommandChanging, propertyChanged: CommandElement.OnCommandChanged);
+
+ public ICommand Command
+ {
+ get => (ICommand)GetValue(CommandProperty);
+ set => SetValue(CommandProperty, value);
+ }
+
+ public static readonly BindableProperty CommandParameterProperty = BindableProperty.Create(nameof(CommandParameter), typeof(object), typeof(CheckBox), null, propertyChanged: CommandElement.OnCommandParameterChanged);
+
+ public object CommandParameter
+ {
+ get => GetValue(CommandParameterProperty);
+ set => SetValue(CommandParameterProperty, value);
+ }
+
/// Bindable property for .
public static readonly BindableProperty ColorProperty = ColorElement.ColorProperty;
@@ -44,9 +73,13 @@ public bool IsChecked
protected internal override void ChangeVisualState()
{
if (IsEnabled && IsChecked)
+ {
VisualStateManager.GoToState(this, IsCheckedVisualState);
+ }
else
+ {
base.ChangeVisualState();
+ }
}
public event EventHandler CheckedChanged;
@@ -72,6 +105,13 @@ void IBorderElement.OnBorderColorPropertyChanged(Color oldValue, Color newValue)
bool IBorderElement.IsBackgroundSet() => IsSet(BackgroundProperty);
bool IBorderElement.IsBorderColorSet() => false;
bool IBorderElement.IsBorderWidthSet() => false;
+
+ void ICommandElement.CanExecuteChanged(object sender, EventArgs e) =>
+ RefreshIsEnabledProperty();
+
+ protected override bool IsEnabledCore =>
+ base.IsEnabledCore && CommandElement.GetCanExecute(this);
+
public Paint Foreground => Color?.AsPaint();
bool ICheckBox.IsChecked
@@ -80,4 +120,4 @@ bool ICheckBox.IsChecked
set => SetValue(IsCheckedProperty, value, SetterSpecificity.FromHandler);
}
}
-}
\ No newline at end of file
+}
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 4c8105349500..e07fc2c36369 100644
--- a/src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt
+++ b/src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt
@@ -63,6 +63,7 @@ Microsoft.Maui.Controls.PointerGestureRecognizer.PointerReleasedCommand.get -> S
Microsoft.Maui.Controls.PointerGestureRecognizer.PointerReleasedCommand.set -> void
Microsoft.Maui.Controls.PointerGestureRecognizer.PointerReleasedCommandParameter.get -> object!
Microsoft.Maui.Controls.PointerGestureRecognizer.PointerReleasedCommandParameter.set -> void
+override Microsoft.Maui.Controls.CheckBox.IsEnabledCore.get -> bool
override Microsoft.Maui.Controls.GradientBrush.IsEmpty.get -> bool
override Microsoft.Maui.Controls.Handlers.Compatibility.TableViewModelRenderer.GetItemViewType(int position) -> int
override Microsoft.Maui.Controls.Handlers.Compatibility.TableViewRenderer.OnMeasure(int widthMeasureSpec, int heightMeasureSpec) -> void
@@ -131,6 +132,10 @@ Microsoft.Maui.Controls.VisualElement.RefreshIsEnabledProperty() -> void
override Microsoft.Maui.Controls.Button.IsEnabledCore.get -> bool
override Microsoft.Maui.Controls.ImageButton.IsEnabledCore.get -> bool
override Microsoft.Maui.Controls.SearchBar.IsEnabledCore.get -> bool
+~Microsoft.Maui.Controls.CheckBox.Command.get -> System.Windows.Input.ICommand
+~Microsoft.Maui.Controls.CheckBox.Command.set -> void
+~Microsoft.Maui.Controls.CheckBox.CommandParameter.get -> object
+~Microsoft.Maui.Controls.CheckBox.CommandParameter.set -> void
~Microsoft.Maui.Controls.InputView.FontFamily.get -> string
~Microsoft.Maui.Controls.InputView.FontFamily.set -> void
~Microsoft.Maui.Controls.WebView.UserAgent.get -> string
@@ -142,6 +147,8 @@ override Microsoft.Maui.Controls.SearchBar.IsEnabledCore.get -> bool
~override Microsoft.Maui.Controls.Region.Equals(object obj) -> bool
~override Microsoft.Maui.Controls.Shapes.Matrix.Equals(object obj) -> bool
~static Microsoft.Maui.Controls.Region.FromRectangles(System.Collections.Generic.IEnumerable rectangles) -> Microsoft.Maui.Controls.Region
+~static readonly Microsoft.Maui.Controls.CheckBox.CommandParameterProperty -> Microsoft.Maui.Controls.BindableProperty
+~static readonly Microsoft.Maui.Controls.CheckBox.CommandProperty -> Microsoft.Maui.Controls.BindableProperty
~static readonly Microsoft.Maui.Controls.InputView.CursorPositionProperty -> Microsoft.Maui.Controls.BindableProperty
~static readonly Microsoft.Maui.Controls.InputView.FontAttributesProperty -> Microsoft.Maui.Controls.BindableProperty
~static readonly Microsoft.Maui.Controls.InputView.FontAutoScalingEnabledProperty -> 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 d050d5ef499d..53d7dadbeb96 100644
--- a/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt
+++ b/src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt
@@ -1,4 +1,5 @@
#nullable enable
+override Microsoft.Maui.Controls.CheckBox.IsEnabledCore.get -> bool
override Microsoft.Maui.Controls.Handlers.Compatibility.CellRenderer.Invoke(string! command, object? args) -> void
override Microsoft.Maui.Controls.Handlers.Compatibility.CellRenderer.UpdateValue(string! property) -> void
override Microsoft.Maui.Controls.Handlers.Compatibility.ShellRenderer.PreferredStatusBarUpdateAnimation.get -> UIKit.UIStatusBarAnimation
@@ -143,6 +144,10 @@ static Microsoft.Maui.Controls.Shapes.Matrix.operator ==(Microsoft.Maui.Controls
Microsoft.Maui.Controls.DragEventArgs.PlatformArgs.get -> Microsoft.Maui.Controls.PlatformDragEventArgs?
Microsoft.Maui.Controls.DragStartingEventArgs.PlatformArgs.get -> Microsoft.Maui.Controls.PlatformDragStartingEventArgs?
Microsoft.Maui.Controls.DropEventArgs.PlatformArgs.get -> Microsoft.Maui.Controls.PlatformDropEventArgs?
+~Microsoft.Maui.Controls.CheckBox.Command.get -> System.Windows.Input.ICommand
+~Microsoft.Maui.Controls.CheckBox.Command.set -> void
+~Microsoft.Maui.Controls.CheckBox.CommandParameter.get -> object
+~Microsoft.Maui.Controls.CheckBox.CommandParameter.set -> void
~Microsoft.Maui.Controls.Handlers.Compatibility.FrameRenderer.FrameRenderer(Microsoft.Maui.IPropertyMapper mapper) -> void
~Microsoft.Maui.Controls.Handlers.Compatibility.FrameRenderer.FrameRenderer(Microsoft.Maui.IPropertyMapper mapper, Microsoft.Maui.CommandMapper commandMapper) -> void
override Microsoft.Maui.Controls.View.ChangeVisualState() -> void
@@ -168,6 +173,8 @@ override Microsoft.Maui.Controls.SearchBar.IsEnabledCore.get -> bool
~override Microsoft.Maui.Controls.Region.Equals(object obj) -> bool
~override Microsoft.Maui.Controls.Shapes.Matrix.Equals(object obj) -> bool
~static Microsoft.Maui.Controls.Region.FromRectangles(System.Collections.Generic.IEnumerable rectangles) -> Microsoft.Maui.Controls.Region
+~static readonly Microsoft.Maui.Controls.CheckBox.CommandParameterProperty -> Microsoft.Maui.Controls.BindableProperty
+~static readonly Microsoft.Maui.Controls.CheckBox.CommandProperty -> Microsoft.Maui.Controls.BindableProperty
~static readonly Microsoft.Maui.Controls.InputView.CursorPositionProperty -> Microsoft.Maui.Controls.BindableProperty
~static readonly Microsoft.Maui.Controls.InputView.FontAttributesProperty -> Microsoft.Maui.Controls.BindableProperty
~static readonly Microsoft.Maui.Controls.InputView.FontAutoScalingEnabledProperty -> 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 03bd016d49ea..a8201b8cd51a 100644
--- a/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
+++ b/src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
@@ -1,4 +1,5 @@
#nullable enable
+override Microsoft.Maui.Controls.CheckBox.IsEnabledCore.get -> bool
override Microsoft.Maui.Controls.Handlers.Compatibility.CellRenderer.Invoke(string! command, object? args) -> void
override Microsoft.Maui.Controls.Handlers.Compatibility.CellRenderer.UpdateValue(string! property) -> void
override Microsoft.Maui.Controls.GradientBrush.IsEmpty.get -> bool
@@ -139,6 +140,10 @@ static Microsoft.Maui.Controls.Region.operator !=(Microsoft.Maui.Controls.Region
static Microsoft.Maui.Controls.Region.operator ==(Microsoft.Maui.Controls.Region left, Microsoft.Maui.Controls.Region right) -> bool
static Microsoft.Maui.Controls.Shapes.Matrix.operator !=(Microsoft.Maui.Controls.Shapes.Matrix left, Microsoft.Maui.Controls.Shapes.Matrix right) -> bool
static Microsoft.Maui.Controls.Shapes.Matrix.operator ==(Microsoft.Maui.Controls.Shapes.Matrix left, Microsoft.Maui.Controls.Shapes.Matrix right) -> bool
+~Microsoft.Maui.Controls.CheckBox.Command.get -> System.Windows.Input.ICommand
+~Microsoft.Maui.Controls.CheckBox.Command.set -> void
+~Microsoft.Maui.Controls.CheckBox.CommandParameter.get -> object
+~Microsoft.Maui.Controls.CheckBox.CommandParameter.set -> void
~Microsoft.Maui.Controls.Handlers.Compatibility.FrameRenderer.FrameRenderer(Microsoft.Maui.IPropertyMapper mapper) -> void
~Microsoft.Maui.Controls.Handlers.Compatibility.FrameRenderer.FrameRenderer(Microsoft.Maui.IPropertyMapper mapper, Microsoft.Maui.CommandMapper commandMapper) -> void
override Microsoft.Maui.Controls.View.ChangeVisualState() -> void
@@ -164,6 +169,8 @@ override Microsoft.Maui.Controls.SearchBar.IsEnabledCore.get -> bool
~override Microsoft.Maui.Controls.Region.Equals(object obj) -> bool
~override Microsoft.Maui.Controls.Shapes.Matrix.Equals(object obj) -> bool
~static Microsoft.Maui.Controls.Region.FromRectangles(System.Collections.Generic.IEnumerable rectangles) -> Microsoft.Maui.Controls.Region
+~static readonly Microsoft.Maui.Controls.CheckBox.CommandParameterProperty -> Microsoft.Maui.Controls.BindableProperty
+~static readonly Microsoft.Maui.Controls.CheckBox.CommandProperty -> Microsoft.Maui.Controls.BindableProperty
~static readonly Microsoft.Maui.Controls.InputView.CursorPositionProperty -> Microsoft.Maui.Controls.BindableProperty
~static readonly Microsoft.Maui.Controls.InputView.FontAttributesProperty -> Microsoft.Maui.Controls.BindableProperty
~static readonly Microsoft.Maui.Controls.InputView.FontAutoScalingEnabledProperty -> 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 93d38a519a45..12286450edba 100644
--- a/src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt
+++ b/src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt
@@ -52,6 +52,7 @@ Microsoft.Maui.Controls.InputView.FontSize.get -> double
Microsoft.Maui.Controls.InputView.FontSize.set -> void
Microsoft.Maui.Controls.InputView.SelectionLength.get -> int
Microsoft.Maui.Controls.InputView.SelectionLength.set -> void
+override Microsoft.Maui.Controls.CheckBox.IsEnabledCore.get -> bool
override Microsoft.Maui.Controls.GradientBrush.IsEmpty.get -> bool
override Microsoft.Maui.Controls.Label.ArrangeOverride(Microsoft.Maui.Graphics.Rect bounds) -> Microsoft.Maui.Graphics.Size
static Microsoft.Maui.Controls.Handlers.ShellItemHandler.MapTitle(Microsoft.Maui.Controls.Handlers.ShellItemHandler! handler, Microsoft.Maui.Controls.ShellItem! item) -> void
@@ -128,6 +129,10 @@ static Microsoft.Maui.Controls.Region.operator ==(Microsoft.Maui.Controls.Region
static Microsoft.Maui.Controls.Shapes.Matrix.operator !=(Microsoft.Maui.Controls.Shapes.Matrix left, Microsoft.Maui.Controls.Shapes.Matrix right) -> bool
static Microsoft.Maui.Controls.Shapes.Matrix.operator ==(Microsoft.Maui.Controls.Shapes.Matrix left, Microsoft.Maui.Controls.Shapes.Matrix right) -> bool
virtual Microsoft.Maui.Controls.Handlers.ShellItemHandler.UpdateAppearance(Microsoft.Maui.Controls.IShellAppearanceElement! appearance) -> void
+~Microsoft.Maui.Controls.CheckBox.Command.get -> System.Windows.Input.ICommand
+~Microsoft.Maui.Controls.CheckBox.Command.set -> void
+~Microsoft.Maui.Controls.CheckBox.CommandParameter.get -> object
+~Microsoft.Maui.Controls.CheckBox.CommandParameter.set -> void
~Microsoft.Maui.Controls.Handlers.Compatibility.FrameRenderer.FrameRenderer(Microsoft.Maui.IPropertyMapper mapper) -> void
~Microsoft.Maui.Controls.Handlers.Compatibility.FrameRenderer.FrameRenderer(Microsoft.Maui.IPropertyMapper mapper, Microsoft.Maui.CommandMapper commandMapper) -> void
override Microsoft.Maui.Controls.View.ChangeVisualState() -> void
@@ -148,6 +153,8 @@ override Microsoft.Maui.Controls.SearchBar.IsEnabledCore.get -> bool
~override Microsoft.Maui.Controls.Shapes.Matrix.Equals(object obj) -> bool
~static Microsoft.Maui.Controls.Handlers.ShellHandler.MapFlyoutIcon(Microsoft.Maui.Controls.Handlers.ShellHandler handler, Microsoft.Maui.Controls.Shell view) -> void
~static Microsoft.Maui.Controls.Region.FromRectangles(System.Collections.Generic.IEnumerable rectangles) -> Microsoft.Maui.Controls.Region
+~static readonly Microsoft.Maui.Controls.CheckBox.CommandParameterProperty -> Microsoft.Maui.Controls.BindableProperty
+~static readonly Microsoft.Maui.Controls.CheckBox.CommandProperty -> Microsoft.Maui.Controls.BindableProperty
~static readonly Microsoft.Maui.Controls.InputView.CursorPositionProperty -> Microsoft.Maui.Controls.BindableProperty
~static readonly Microsoft.Maui.Controls.InputView.FontAttributesProperty -> Microsoft.Maui.Controls.BindableProperty
~static readonly Microsoft.Maui.Controls.InputView.FontAutoScalingEnabledProperty -> 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 334899e1ffa1..797c00f9b04e 100644
--- a/src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt
+++ b/src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt
@@ -51,6 +51,7 @@ Microsoft.Maui.Controls.PointerGestureRecognizer.PointerReleasedCommand.get -> S
Microsoft.Maui.Controls.PointerGestureRecognizer.PointerReleasedCommand.set -> void
Microsoft.Maui.Controls.PointerGestureRecognizer.PointerReleasedCommandParameter.get -> object!
Microsoft.Maui.Controls.PointerGestureRecognizer.PointerReleasedCommandParameter.set -> void
+override Microsoft.Maui.Controls.CheckBox.IsEnabledCore.get -> bool
Microsoft.Maui.Controls.TimeChangedEventArgs
Microsoft.Maui.Controls.TimeChangedEventArgs.NewTime.get -> System.TimeSpan
Microsoft.Maui.Controls.TimeChangedEventArgs.OldTime.get -> System.TimeSpan
@@ -106,6 +107,10 @@ Microsoft.Maui.Controls.VisualElement.RefreshIsEnabledProperty() -> void
override Microsoft.Maui.Controls.Button.IsEnabledCore.get -> bool
override Microsoft.Maui.Controls.ImageButton.IsEnabledCore.get -> bool
override Microsoft.Maui.Controls.SearchBar.IsEnabledCore.get -> bool
+~Microsoft.Maui.Controls.CheckBox.Command.get -> System.Windows.Input.ICommand
+~Microsoft.Maui.Controls.CheckBox.Command.set -> void
+~Microsoft.Maui.Controls.CheckBox.CommandParameter.get -> object
+~Microsoft.Maui.Controls.CheckBox.CommandParameter.set -> void
~Microsoft.Maui.Controls.InputView.FontFamily.get -> string
~Microsoft.Maui.Controls.InputView.FontFamily.set -> void
~Microsoft.Maui.Controls.WebView.UserAgent.get -> string
@@ -117,6 +122,8 @@ override Microsoft.Maui.Controls.SearchBar.IsEnabledCore.get -> bool
~static Microsoft.Maui.Controls.RadioButton.MapContent(Microsoft.Maui.Handlers.IRadioButtonHandler handler, Microsoft.Maui.Controls.RadioButton radioButton) -> void
~static Microsoft.Maui.Controls.RadioButton.MapContent(Microsoft.Maui.Handlers.RadioButtonHandler handler, Microsoft.Maui.Controls.RadioButton radioButton) -> void
~static Microsoft.Maui.Controls.Region.FromRectangles(System.Collections.Generic.IEnumerable rectangles) -> Microsoft.Maui.Controls.Region
+~static readonly Microsoft.Maui.Controls.CheckBox.CommandParameterProperty -> Microsoft.Maui.Controls.BindableProperty
+~static readonly Microsoft.Maui.Controls.CheckBox.CommandProperty -> Microsoft.Maui.Controls.BindableProperty
~static readonly Microsoft.Maui.Controls.ContentPage.HideSoftInputOnTappedProperty -> Microsoft.Maui.Controls.BindableProperty
~static readonly Microsoft.Maui.Controls.InputView.CursorPositionProperty -> Microsoft.Maui.Controls.BindableProperty
~static readonly Microsoft.Maui.Controls.InputView.FontAttributesProperty -> 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 212b98d66c3e..ceef6ed694ea 100644
--- a/src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt
+++ b/src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt
@@ -49,6 +49,7 @@ Microsoft.Maui.Controls.PointerGestureRecognizer.PointerReleasedCommand.get -> S
Microsoft.Maui.Controls.PointerGestureRecognizer.PointerReleasedCommand.set -> void
Microsoft.Maui.Controls.PointerGestureRecognizer.PointerReleasedCommandParameter.get -> object!
Microsoft.Maui.Controls.PointerGestureRecognizer.PointerReleasedCommandParameter.set -> void
+override Microsoft.Maui.Controls.CheckBox.IsEnabledCore.get -> bool
Microsoft.Maui.Controls.TimeChangedEventArgs
Microsoft.Maui.Controls.TimeChangedEventArgs.NewTime.get -> System.TimeSpan
Microsoft.Maui.Controls.TimeChangedEventArgs.OldTime.get -> System.TimeSpan
@@ -125,6 +126,10 @@ Microsoft.Maui.Controls.VisualElement.RefreshIsEnabledProperty() -> void
override Microsoft.Maui.Controls.Button.IsEnabledCore.get -> bool
override Microsoft.Maui.Controls.ImageButton.IsEnabledCore.get -> bool
override Microsoft.Maui.Controls.SearchBar.IsEnabledCore.get -> bool
+~Microsoft.Maui.Controls.CheckBox.Command.get -> System.Windows.Input.ICommand
+~Microsoft.Maui.Controls.CheckBox.Command.set -> void
+~Microsoft.Maui.Controls.CheckBox.CommandParameter.get -> object
+~Microsoft.Maui.Controls.CheckBox.CommandParameter.set -> void
~Microsoft.Maui.Controls.Element.AddLogicalChild(Microsoft.Maui.Controls.Element element) -> void
~Microsoft.Maui.Controls.Element.InsertLogicalChild(int index, Microsoft.Maui.Controls.Element element) -> void
~Microsoft.Maui.Controls.Element.RemoveLogicalChild(Microsoft.Maui.Controls.Element element) -> bool
@@ -144,6 +149,8 @@ Microsoft.Maui.Controls.Xaml.RequireServiceAttribute
~static Microsoft.Maui.Controls.RadioButton.MapContent(Microsoft.Maui.Handlers.IRadioButtonHandler handler, Microsoft.Maui.Controls.RadioButton radioButton) -> void
~static Microsoft.Maui.Controls.RadioButton.MapContent(Microsoft.Maui.Handlers.RadioButtonHandler handler, Microsoft.Maui.Controls.RadioButton radioButton) -> void
~static Microsoft.Maui.Controls.Region.FromRectangles(System.Collections.Generic.IEnumerable rectangles) -> Microsoft.Maui.Controls.Region
+~static readonly Microsoft.Maui.Controls.CheckBox.CommandParameterProperty -> Microsoft.Maui.Controls.BindableProperty
+~static readonly Microsoft.Maui.Controls.CheckBox.CommandProperty -> Microsoft.Maui.Controls.BindableProperty
~static readonly Microsoft.Maui.Controls.InputView.CursorPositionProperty -> Microsoft.Maui.Controls.BindableProperty
~static readonly Microsoft.Maui.Controls.InputView.FontAttributesProperty -> Microsoft.Maui.Controls.BindableProperty
~static readonly Microsoft.Maui.Controls.InputView.FontAutoScalingEnabledProperty -> Microsoft.Maui.Controls.BindableProperty
diff --git a/src/Controls/tests/Core.UnitTests/CheckBoxUnitTests.cs b/src/Controls/tests/Core.UnitTests/CheckBoxUnitTests.cs
index faba353370e2..41a3e2ab70bf 100644
--- a/src/Controls/tests/Core.UnitTests/CheckBoxUnitTests.cs
+++ b/src/Controls/tests/Core.UnitTests/CheckBoxUnitTests.cs
@@ -63,5 +63,36 @@ public void CheckedVisualStates()
element.IsChecked = false;
Assert.NotEqual(checkedStateName, stateGroup.CurrentState.Name);
}
+
+
+ [Fact]
+ public void CheckBoxClickWhenCommandCanExecuteFalse()
+ {
+ bool invoked = false;
+ var checkBox = new CheckBox()
+ {
+ Command = new Command(() => invoked = true, () => false),
+ IsChecked = false
+ };
+
+ checkBox.IsChecked = true;
+
+ Assert.False(invoked);
+ }
+
+ [Fact]
+ public void CheckBoxClickWhenCommandCanExecuteTrue()
+ {
+ bool invoked = false;
+ var checkBox = new CheckBox()
+ {
+ Command = new Command(() => invoked = true, () => true),
+ IsChecked = false
+ };
+
+ checkBox.IsChecked = true;
+
+ Assert.True(invoked);
+ }
}
}