Yes! There is a better way called binding. Out of bounds, you're pretty much stuck (I can imagine how to handle all the marked events separately and assign an enumeration, but is this really better?)
For switches, you usually use enumto represent all possible values:
public enum OsTypes
{
Windows7_32,
Windows7_64
}
"" . ValueEqualsConverter:
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return value.Equals(parameter);
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return ((bool)value) ? parameter : Binding.DoNothing;
}
:
<RadioButton Content="Windows 7 32-bit"
IsChecked= "{Binding CurrentOs,
Converter={StaticResource ValueEqualsConverter},
ConverterParameter={x:Static local:OsTypes.Windows7_32}}"
, :
public OsTypes CurrentOs {get; set;}
x: , switch - . , . MVVM WPF, !