Используется конвертер для преобразования Bools к междунар :
На Xaml, варианты опций сопоставляются с 1,2,3 по вашему свойству MyChoice :
<RadioButton GroupName="Option" Content="Option 1"
IsChecked="{Binding Path=MyChoice, Converter={StaticResource RadioButtonToIntConverter},
ConverterParameter=1}"/>
<RadioButton GroupName="Option" Content="Option 2"
IsChecked="{Binding Path=MyChoice, Converter={StaticResource RadioButtonToIntConverter},
ConverterParameter=2}"/>
<RadioButton GroupName="Option" Content="Option 3"
IsChecked="{Binding Path=MyChoice, Converter={StaticResource RadioButtonToIntConverter},
ConverterParameter=3}"/>
В преобразователе, отметив, что я не добавил никакой защиты произнесения:
public class RadioButtonToIntConverter:IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var para = System.Convert.ToInt32(parameter);
var myChoice = System.Convert.ToInt32(value);
return para == myChoice;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
var para = System.Convert.ToInt32(parameter);
var isChecked = System.Convert.ToBoolean(value);
return isChecked ? para : Binding.DoNothing;
}
}
Кроме того, вы бы лучше реализовать INotifyPropertyChanged в вас ViewModel.