I want to create an enumcombobox where the popup will show the enumvalues of the controls' binding object. Somehow I cannot get the binding object property at runtime. Databindings wil get me to the binding object. But the property and its type is invisable for me, or I just didn't find it yet... Can anyone help me with this?
Asked
Active
Viewed 377 times
0
-
Duplicate question... see this one : http://stackoverflow.com/questions/538072/what-is-the-best-way-to-populate-a-wpf-combo-box-with-all-items-from-a-given-enum/848187#848187 – Thomas Levesque May 29 '09 at 12:54
1 Answers
0
You have to use a DataObjectProvider. In your resources, put something like :
<ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type sys:Enum}" x:Key="odpEnum">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="yourEnumNameHere"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
In your combo, put :
<ComboBox ItemsSource="{Binding Source={StaticResource odpEnum}}"/>
This should fill your combo with your enum.

rockeye
- 2,765
- 2
- 30
- 44