我有一个自定义样式的Combobox工作正常。它放置在一个用户控件中并绑定到一个数据结构。我使用DisplayMemberPath在Combobox文本框中只显示一个元素。组合框样式取自MSDN并多次使用。所以它不显示在这里。wpf调试错误输出System.WIndows.Data错误25
<UserControl x:Class="wpf.projext1.MyComboBox"
x:Name="MyControl"
...
<ComboBox Style="{StaticResource ComboBoxStyle}"
Text="{Binding ElementName=MyControl, Path=Text}"
IsEditable="True"
IsTextSearchEnabled="False"
StaysOpenOnEdit="True"
ItemsSource="{Binding ElementName=MyControl, Path=MyItemsSource}"
DisplayMemberPath="Name"
</ComboBox
我得到以下恼人的错误信息填充输出窗口:
System.Windows.Data Error: 25 : Both 'ContentTemplate' and 'ContentTemplateSelector' are set; 'ContentTemplateSelector' will be ignored. ComboBoxItem:'ComboBoxItem' (Name='')
,如果我离开了
DisplayMemberPath="Name"
...显示有关错误25没有调试输出。但我绝对需要DiplayMemberPath =“名称”! 你有想法解决这个问题吗?
在你的Style'ComboBoxStyle'中,你可能会为你设置ItemTemplate组合框。因此,这个错误。 – 2013-03-27 09:24:38