我收到了一个非常不寻常的错误,该项目用于在我尝试将ENUM绑定到组合框的工程中。为了确保我没有犯过编码错误,我使用SO Question 58743和ageektrapped作为自包含用户控件的样本进行了新的用户控制。我使用.Net4 Client Framework作为环境和VS2010。该XAML是 -数据绑定枚举组合框
<UserControl x:Class="Barcode.Views.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:System="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300">
<UserControl.Resources>
<ObjectDataProvider MethodName="GetValues"
ObjectType="{x:Type System:Enum}"
x:Key="AlignmentValues">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="HorizontalAlignment" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</UserControl.Resources>
<Grid>
<ComboBox Name="myComboBox" SelectedIndex="0" Margin="8"
ItemsSource="{Binding Source={StaticResource AlignmentValues}}" />
</Grid>
</UserControl>
是我得到的组合框的错误是错误144无法构建项目后投类型“System.String”的对象键入“System.Windows.DataTemplate” 。
我不知道什么可能导致此错误。
移动了以下评论 – 2011-01-21 17:12:47