I have the following converter:
public class EnumDescriptionConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter,
CultureInfo culture)
{
var enumValue = (MyEnum)value;
//GetDescription is method to read attribute string value.
return enumValue.GetDescription();
}
}
I have a listbox:
<ListBoxItem Content=
"{Binding {x:Static Enums:MyEnum.Video}, Converter={StaticResource DescriptionConverter}}"/>
When I run this, I get exception “unable to cast MyEnum to string”. Breakpoint inside converter is not triggered.
What is wrong?
You’re trying to bind the Enum to the Binding’s
PathpropertySpecify that the Enum is the
Sourceproperty instead