Articles in this section
Category / Section

How to get the selected Xamarin.Forms Radio Button?

1 min read

This article explains how to get the selected Xamarin.Forms RadioButton from the RadioGroup and it has been achieved by using any of the following solutions.

 

Solution 1:

You can get the selected RadioButton in the RadioGroup by using the CheckedItem property of RadioGroup as per the below code snippet.

 

XAML:

<Button Text="Get Checked RadioButton" Clicked="Button_Clicked"/>
<syncfusion:SfRadioGroup x:Name="radioGroup"
          BindableLayout.ItemsSource="{Binding RadioGroupData}">
            <BindableLayout.ItemTemplate>
                <DataTemplate>
                    <syncfusion:SfRadioButton 
                          Text="{Binding Name}" />
                </DataTemplate>
            </BindableLayout.ItemTemplate>
</syncfusion:SfRadioGroup>

 

C#:

public partial class MainPage : ContentPage
{
       public MainPage()
       {
           InitializeComponent();
       }
        
       private void Button_Clicked(object sender, EventArgs e)
       {
           var selecteddRadioButton = radioGroup.CheckedItem;
           ……
        }
}

 

Solution 2:

You can also use the CheckedChanged event to get the selected RadioButton in RadioGroup, which has been invoked while changing the selection in the RadioGroup. The below code example shows how to get the selected RadioButton through CheckedChanged argument.

 

XAML:

<syncfusion:SfRadioGroup BindableLayout.ItemsSource="{Binding RadioGroupData}"
                   CheckedChanged="CheckedChanged_event">
      <BindableLayout.ItemTemplate>
                <DataTemplate>
                    <syncfusion:SfRadioButton Text="{Binding Name}" />
                </DataTemplate>
      </BindableLayout.ItemTemplate>
</syncfusion:SfRadioGroup>

 

C#:

private void CheckedChanged_event(object sender, Syncfusion.XForms.Buttons.CheckedChangedEventArgs e)
{
       // To get the selected RadioButton - e.CurrentItem
      // To get the previously selected RadioButton -  e.PreviousItem
}

See Also:

How to customize the Xamarin.Forms RadioButton

How to notify the state of Xamarin.Forms RadioButton has changed

Available states in Xamarin.Forms RadioButton

How to create a Xamarin.Forms RadioButton in XAML


Conclusion

I hope you enjoyed learning about how to get the selected Xamarin.Forms Radio Button.

You can refer to our Xamarin.Forms Radio Button feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments
Please  to leave a comment
Access denied
Access denied