Articles in this section
Category / Section

How to notify the selection changes in Xamarin.Forms RadioButton [SfRadioButton]

1 min read

This article shows how to notify the popup by displaying the text of a selected RadioButton while changing the selection on the radio button list as follows.


public class Model : INotifyPropertyChanged
        private bool isChecked;
        private ICommand stateChangedCommand;
        public ICommand StateChangedCommand
            get { return stateChangedCommand; }
                stateChangedCommand = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("StateChangedCommand"));
        public bool IsChecked
            get { return isChecked; }
                isChecked = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IsChecked"));
        public Model()
            StateChangedCommand = new Command(OutputValue);
        void OutputValue(object person)
            if (IsChecked)
                App.Current.MainPage.DisplayAlert("Message", "Selected Language", (person as SfRadioButton).Text);
        public event PropertyChangedEventHandler PropertyChanged;



  <buttons:SfRadioGroup x:Name="radioGroup" BindableLayout.ItemsSource="{Binding Items}">
                    <buttons:SfRadioButton x:Name="radioButton" IsChecked="{Binding IsChecked}" Text="{Binding Item}">
                                             Command="{Binding StateChangedCommand}"
                                             CommandParameter="{x:Reference radioButton}"/>


Now, when tapped on the SfRadioButton, the corresponding command in ViewModel will be invoked automatically and the desired operation will be performed as shown in the following screenshot.


Xamarin.Forms SfRadioButton with MVVM Pattern


Download the complete sample here.


Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment