Events in .NET MAUI Radio Button (SfRadioButton)

21 May 20253 minutes to read

StateChanged event

The StateChanged event occurs when the value (state) of the IsChecked property is changed, either by user interaction or programmatically via XAML or C# code. The event arguments are of type StateChangedEventArgs and expose the following property:

<syncfusion:SfRadioGroup x:Name="radioGroup">
    <syncfusion:SfRadioButton x:Name="check" Text="Checked State" IsChecked="True" StateChanged="RadioButton_StateChanged"/>
    <syncfusion:SfRadioButton x:Name="uncheck" Text="Unchecked  State" StateChanged="RadioButton_StateChanged"/>
</syncfusion:SfRadioGroup>
SfRadioGroup radioGroup = new SfRadioGroup();
SfRadioButton check = new SfRadioButton();
check.Text = "Checked State";
check.IsChecked = true;
check.StateChanged += RadioButton_StateChanged;
SfRadioButton uncheck = new SfRadioButton();
uncheck.Text = "Unchecked State";
uncheck.StateChanged += RadioButton_StateChanged;
radioGroup.Children.Add(check);
radioGroup.Children.Add(uncheck);
this.Content = radioGroup;
private void RadioButton_StateChanged(object sender, Syncfusion.Maui.Buttons.StateChangedEventArgs e)
{
    if (e.IsChecked.HasValue && e.IsChecked.Value)
    {
        (sender as SfRadioButton).Text = "Checked State";
    }
    else if (e.IsChecked.HasValue && !e.IsChecked.Value)
    {
        (sender as SfRadioButton).Text = "Unchecked State";
    }
}

StateChanged event 1
StateChanged event 2

StateChanging event

The StateChanging event is triggered when the state of the IsChecked property is about to change, typically by tapping the Radio Button control. The event arguments are of type StateChangingEventArgs and provide the following properties:

  • IsChecked : The new value(state) of the IsChecked property.
  • Cancel : Gets or sets a value indicating whether the event should be canceled.
<syncfusion:SfRadioGroup x:Name="radioGroup">
    <syncfusion:SfRadioButton x:Name="check" Text="Checked State" IsChecked="True" StateChanging="OnStateChanging"/>
    <syncfusion:SfRadioButton x:Name="uncheck" Text="Unchecked State"/>
</syncfusion:SfRadioGroup>
SfRadioGroup radioGroup = new SfRadioGroup();
SfRadioButton check = new SfRadioButton();
check.Text = "Checked State";
check.IsChecked = true;
check.StateChanging += OnStateChanging;
SfRadioButton uncheck = new SfRadioButton();
uncheck.Text = "Unchecked State";
uncheck.StateChanging += OnStateChanging;
radioGroup.Children.Add(check);
radioGroup.Children.Add(uncheck);
this.Content = radioGroup;
private void OnStateChanging(object sender, StateChangingEventArgs e)
{
    e.cancel=true;
}