我收到了一個非常不尋常的錯誤,該項目用於在我嘗試將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