views:

42

answers:

1

Hello,

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?

A: 

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