Problem: Binding a property of type Enum to RadioButtons, using parameterized Converter. No exception thrown, Radiobutton might have validation problems (not sure). Red box around RadioButtons is shown when testing.
Info: Was trying to use the solution given in How to bind RadioButtons to an enum?
I've got an Enum like this:
namespace crmVerwaltungstools.Models
{
public enum CrmSystemType
{
Training = 0,
Live = 1
}
}
BooleanToEnumConverter:
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 value.Equals(true) ? (CrmSystemType)parameter : Binding.DoNothing;
}
and inside my Window:
xmlns:models="clr-namespace:crmVerwaltungstool.Models"
<StackPanel Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" Orientation="Horizontal">
<StackPanel.Resources>
<converter:RadioButtonIsCheckedToCrmSystemTypeConverter x:Key="RbIsCheckedToCrmSystemTypeConverter" />
</StackPanel.Resources>
<RadioButton Content="Schulungs-System" GroupName="rbg_SelectSystem"
IsChecked="{Binding Path=SystemType, Converter={StaticResource RbIsCheckedToCrmSystemTypeConverter},
ConverterParameter={x:Static models:CrmSystemType.Training}}"/>
<RadioButton Content="Live-System" GroupName="rbg_SelectSystem"
IsChecked="{Binding Path=SystemType, Converter={StaticResource RbIsCheckedToCrmSystemTypeConverter},
ConverterParameter={x:Static models:CrmSystemType.Live}}"/>
</StackPanel>
Can't see any mistakes. (Maybe just saw too much lines of code today...)
Thanks for helping!!