Here are the DataTemplates:
<DataTemplate DataType="{x:Type data:Item}" x:Key="ItemTemplate">
<Border/>
</DataTemplate>
<DataTemplate DataType="{x:Type data:StyleI开发者_如何学运维tem}" x:Key="StyleItemTemplate">
<Border>
<ContentControl Content="{Binding Item}"
ContentTemplate="{StaticResource ItemTemplate}"/>
</Border>
</DataTemplate>
I am trying to bind a List<StyleItem>
to an ItemsControl,
ItemTemplate="{StaticResource StyleItemTemplate}"
, but then I get a System.Reflection.AmbiguousMatchException
.
I read this post, and althoug the StyleItem and Item classes are not generic classes, anyhow; I don't know how to use the parenthsis solution in my situation.
The Item
and StyleItem
classes are generated EF entities that inherit from System.Data.Objects.DataClasses.EntityObject
, and implement System.ComponentModel.IDataErrorInfo
.
This smells like a collision between your StyleItem.Item
property and the property indexer defined in IDataErrorInfo
. Try changing the name of your StyleItem.Item
property to something else.
You should either use the x:Key property or the DataType property.
You must not use both. So remove either one to get it to work! I suggest removing the DataType property, since you already use the keys in your example!
精彩评论