I know there are several ways to do it, but I would like to make it even easier if possible because I have a lot of comboboxes to bind in this way. There is a suggestion usi
You would be better off with a MarkupExtension, like this one.
CodeNaked posts a great way of doing this
For your approach to work you can change the converter to Enum.GetValues(value as Type)
and use the x:Type
syntax as Source for the Binding
ItemsSource="{Binding Source={x:Type local:MyValues},
Converter={StaticResource EnumToArrayConverter}}"
EnumToArrayConverter
public class EnumToArrayConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return Enum.GetValues(value as Type);
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return null; // I don't care about this
}
}