I have a DataGrid bound to a class where one of the properties is of a run-time Enum type created using EnumBuilder. I wish to have the Column automatically detect the enumerators in the enum and display them in a drop-down box on the cell (a ComboBox).
I understand that if the enum was defined at design-time, I can use the following XAML code to do this:
<ObjectDataProvider x:Key="myEnumValues" MethodName="GetValues" ObjectType="{x:Type sys:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="local:MyClass+MyEnum" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
...
<xcdg:Column>
<xcdg:Column.ForeignKeyConfiguration>
<xcdg:ForeignKeyConfiguration ItemsSource="{Binding Source={StaticResource myEnumValues}}" />
</xcdg:Column.ForeignKeyConfiguration>
</xcdg:Column>
However, how can I achieve the same when I have a property of Enum type in MyClass which I assign using the following code in MyClass constructor?:
MyEnum = (Enum)Activator.CreateInstance(myEnumBuilder.CreateType());
And yes, this does need to be a run-time Enum. Any help greatly appreciated. Thanks!
Associate, .NET Development
Morgan Stanley, UK