How does SfRadioGroup work?

Hi,

I dont understand the purpose of SfRadioGroup, if each syncfusion:SfRadioButton works independently. Basically according to the sample below 2 radio button are not dependent because when i change 1 buttons state, it fires statechanged 2 times for each button.

<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>

private void RadioButton_StateChanged(object sender, 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";
    }
 }

that means doing this below has no difference if i change manuall ischecked of one when other is unchecked. There should be some event over syncfusion:SfRadioGroup level to determine which RadioButton is selected just like a picker because you can only select 1 item. Like that it is not very useful.
<syncfusion:SfRadioButton x:Name="check" Text="Checked State" IsChecked="True" StateChanged="RadioButton_StateChanged"/>
<syncfusion:SfRadioButton x:Name="uncheck" Text="Unchecked  State" StateChanged="RadioButton_StateChanged"/>

4 Replies

EM Emil July 15, 2018 12:16 PM UTC

So I believe that there should some kind of relation when it is grouped similar to segmentcontrol where we have selectedindex. 


KK Karthik Krishnaraj Syncfusion Team July 16, 2018 11:55 AM UTC

Hi Emil, 
 
Thank you for contacting Syncfusion Support, 
 
I don’t understand the purpose of SfRadioGroup, if each syncfusion:SfRadioButton works independently. Basically, according to the sample below 2 radio button are not dependent because when i change 1 buttons state, it fires statechanged 2 times for each button. 
SfRadioGroup allows us to select one option from a list of predefined choices. When you select the radio button in the same group then it will automatically deselect the previous selected radio button. 
 
 For example, if you have the choice for gender as Male or Female with Male is selected as default and when you select the Female then it will automatically deselect the Male. 
 
In the given Xaml, both the “check” and “uncheck” radio buttons are registered to “RadioButton_StateChanged” event and “check” radio button is selected by default. The StateChanged event will fire when the value of IsChecked property is changed. 
 
 When you select the “uncheck” radio button then it will change the IsChecked property of “check” radio button to false and “uncheck” radio button’s IsChecked property as true so it will fire the StateChanged event two times. 
that means doing this below has no difference if i change manuall ischecked of one when other is unchecked. There should be some event over syncfusion:SfRadioGroup level to determine which RadioButton is selected just like a picker because you can only select 1 item. Like that it is not very useful. 
 
We have considered your request as a feature "CheckChanged event for SfRadioGroup” to handle the selection changed in radio buttons. We have logged this as a feature and it will be available in any of our upcoming release 
 
Thanks, 
Karthik. 



MP Martin Publica November 6, 2018 04:01 PM UTC

Hi

Please confirm whether this functionality ("CheckChanged event for SfRadioGroup”) has been added, and if so, in which version? Please also refer me to the documentation for this?

Thanks

Martin


PA Paul Anderson S Syncfusion Team November 7, 2018 07:20 AM UTC

Hi Martin, 
 
Currently we have not implemented the requested feature in SfRadioButton. As the implementation of feature “CheckChanged event for SfRadioGroup” would greatly depend on the factors such as product design, code compatibility and complexity, we will implement this feature in any of our upcoming Volume releases. We will add in our Release notes and UG once implemented. 
 
Kindly visit our website periodically for feature product updates. 
 
Regards, 
Paul Anderson 


Loader.
Up arrow icon