title | page_title | description | position | slug |
---|---|---|---|---|
Check States |
.NET MAUI CheckBox Documentation - Check States |
Define the checked, unchecked, or indeterminate state of the Telerik CheckBox for .NET MAUI. |
2 |
checkbox-checked-states |
The CheckBox enables you to define its state as Checked
, Unchecked
, or Indeterminate
.
The state is controlled through the IsChecked
(bool?
) property. You can set all states either through the UI or programmatically. The Indeterminate
state can be applied through the UI only for three-state checkboxes. IsChecked
property binding mode is TwoWay
.
-
Checked
state—WhenIsChecked
istrue
. -
(Default)
Unchecked
state—WhenIsChecked
isfalse
. -
Indeterminate
state—WhenIsChecked
isnull
. -
IsThreeState
(bool
)—Defines whether you can apply the indeterminate state through the UI. WhenIsThreeState
istrue
, it allows the end user to go to the indeterminate state along with theChecked
andUnchecked
states. By default,IsThreeState
isfalse
.
The following example demonstrates how to set the IsChecked
property.
Define the checked state of the CheckBox.
<telerik:RadCheckBox x:Name="checkboxIsChecked"
IsChecked="{Binding IsChecked}"
IsThreeState="True" />
Set the ViewModel.
public class ViewModel : NotifyPropertyChangedBase
{
private bool? isChecked;
public bool? IsChecked
{
get { return this.isChecked; }
set
{
if (this.isChecked != value)
{
this.isChecked = value;
OnPropertyChanged();
}
}
}
}
IsCheckedChanged
—Occurs when theRadCheckBox.IsChecked
property is changed. TheIsCheckedChanged
event handler receives two parameters:- The
Sender
which is of typeTelerik.Maui.Controls.RadCheckBox
. - and
IsCheckedChangedEventArgs
. TheIsCheckedChangedEventArgs
provides the following properties:NewValue
(bool?
)—Gets the new value from the CheckBox state.OldValue
(bool?
)—Gets the old value of the CheckBox state.
- The
The Telerik .NET MAUI CheckBox allows you to attach a command that executes when the IsChecked
property changes.
Command
(ICommand
)—Defines the command, which executes when theIsChecked
property of the checkbox changes. UseCommandParameter
to pass a parameter to the command execute method. TheCommand
is available in .NET 8.
Here is an example with the CheckBox.Command
1. Define the CheckBox in XAML:
2. Define the ViewModel:
Here is the result:
- [Styling Options of the Checkbox]({%slug checkbox-styling%})