Event in Xamarin CheckBox (SfCheckBox)

21 Aug 20231 minute to read

StateChanged event

Occurs when the value(state) of the IsChecked property is changed by either touching the check box or setting the value to the IsChecked property using XAML or C# code. The event arguments are of type StateChangedEventArgs and expose the following property:

<syncfusion:SfCheckBox x:Name="checkBox" Text="Unchecked State" IsThreeState="True" StateChanged="CheckBox_StateChanged"/>
SfCheckBox checkBox = new SfCheckBox();
checkBox.Text = "Unchecked State";
checkBox.IsThreeState = true;
checkBox.StateChanged += CheckBox_StateChanged;
private void CheckBox_StateChanged(object sender, StateChangedEventArgs e)
{
    if (e.IsChecked.HasValue && e.IsChecked.Value)
    {
        checkBox.Text = "Checked State";
    }
    else if(e.IsChecked.HasValue && !e.IsChecked.Value)
    {
        checkBox.Text = "Unchecked State";
    }
    else
    {
    checkBox.Text = "Indeterminate State";
    }
}

Checked state image
Unchecked state image
Indeterminate state image

See also

How to get the values of selected checkboxes in a group using Xamarin.Forms