Say I have an enum with four values:
public enum CompassHeading
{
North,
South,
East,
West
}
What XAML would be required to have a ComboBox be populated with these items?
<ComboBox ItemsSource="{Binding WhatGoesHere???}" />
Ideally I wouldn't have to set up C# code for this.
You can use the ObjectDataProvider to do this:
<ObjectDataProvider MethodName="GetValues"
ObjectType="{x:Type sys:Enum}" x:Key="odp">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="local:CompassHeading"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<ComboBox ItemsSource="{Binding Source={StaticResource odp}}" />
I found the solution here: