Another way of getting the enum values for use as a data source:
<Window.Resources>
<ObjectDataProvider
MethodName="GetValues"
ObjectType="{x:Type sys:Enum}"
x:Key="TestValues">
<ObjectDataProvider.MethodParameters>
<w:Type2
TypeName="w:Test+TestEnum" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</Window.Resources>
...
ItemsSource="{Binding Source={StaticResource TestValues}}"
Note that you still need the Type2Extension
because of weirdness with TypeExtension
and nested types. But you wouldn’t need the extra custom markup extension. This way is better if you’ll be using the list in multiple places, as you can declare it in your App.xaml
resources.