)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to get the selected Xamarin.Forms RadioButton?

Platform: Xamarin.Forms |
Control: SfRadioButton |
Published Date: January 9, 2020 |
Last Revised Date: January 9, 2020

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

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon