Nael
Nael

Reputation: 1539

Trouble displaying Enums in a Combobox in WF4

I'm trying to follow the solution from this post in my WF4 project: Databinding an enum property to a ComboBox in WPF

And I've implemented the code

<ObjectDataProvider MethodName="GetValues"
    ObjectType="{x:Type s:Enum}"
    x:Key="DayOfWeekValues">
    <ObjectDataProvider.MethodParameters>
        <x:Type TypeName="s:DayOfWeek" />
    </ObjectDataProvider.MethodParameters>
</ObjectDataProvider>

<ComboBox ItemsSource="{Binding Source={StaticResource DayOfWeekValues}}"/>

I'm getting the following error on the TypeName="s:DayOfWeek" property.

Cannot reparent the node "Type(System.DayOfWeek)" from the old parent "IList" to the new parent "ObjectDataProvider".

Any ideas about what this error means?

EDIT: In addition to the error above, I'm also getting the following error on the MethodName="GetValues" property on the ObjectDataProvider.

INCORRECT_PARAMETER_TYPE

Upvotes: 1

Views: 1604

Answers (1)

Louis Rhys
Louis Rhys

Reputation: 35627

Just rebuild (not build) the solution or rebuild the project and it will work just fine.

Upvotes: 5

Related Questions