Fetching selected radio button in wpf

Viewed 5615

In WinForms I've used panel to group radio buttons and then this code to fetch selected radio button

var checkedValue = panelMyPanel.Controls.OfType<RadioButton>()
                        .FirstOrDefault(r => r.Checked);

Now I want to translate this to wpf and inside xaml I added radio buttons

 <RadioButton GroupName="myGroup" Name="Option1" Content="option one" IsChecked="True"  Width="40"/>
 <RadioButton GroupName="myGroup" Name="Option2" Content="option two" IsChecked="False" Width="80"/>
 <RadioButton GroupName="myGroup" Name="Option3" Content="option three" IsChecked="False" Width="60"/>

how to know which radio btn is selected in code behind?

1 Answers
Related