How to pass specific value to the converter parameter?
Try using x:Static
markup extension:
<RadioButton
Content="Female"
IsChecked="{Binding Path=Gender,
Converter={StaticResource genderConverter},
ConverterParameter={x:Static model:GenderType.Female}}"/>
OR, you could just pass a string and use Enum.Parse
to convert that string to the enum type in the converter:
<RadioButton
Content="Female"
IsChecked="{Binding Path=Gender,
Converter={StaticResource genderConverter},
ConverterParameter=Female}"/>
-
GenderType gender = (GenderType)Enum.Parse(typeof(GenderType), parameter.ToString());
Since you're creating your own converter why don't you just send a nullable bool as the converter parameter?
so for male,female,not specified
send true,false,null
.
If you don't want to do that you will have to reference your namespace in the beginning like this:
xmlns:myNamespace="clr-namespace:MyNamespace"
and then
<RadioButton
Content="Male"
IsChecked="{Binding Path=Gender,
Converter={StaticResource genderConverter},
ConverterParameter=x:Static myNamespace:Person.GenderType.Male}"/>
for your radiobuttons.