无法在WF4中的Combobox中显示枚举

时间:2010-09-27 20:46:49

标签: wpf xaml

我正在尝试在我的WF4项目中关注此帖子中的解决方案:Databinding an enum property to a ComboBox in WPF

我已经实现了代码

<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}}"/>

我在TypeName =“s:DayOfWeek”属性上遇到以下错误。

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

关于此错误意味着什么的任何想法?

编辑:除了上述错误之外,我还在ObjectDataProvider上的MethodName =“GetValues”属性中收到以下错误。

INCORRECT_PARAMETER_TYPE

1 个答案:

答案 0 :(得分:5)

只需重建(不构建)解决方案或重建项目,它就可以正常工作。