wpf调试错误输出System.WIndows.Data错误25 [英] wpf debug error output System.WIndows.Data Error 25
问题描述
我有一个自定义样式的Combobox工作正常。它放在用户控件内并绑定到数据结构。我使用DisplayMemberPath在Combobox TextBox中只显示一个元素。 ComboBox风格取自MSDN并使用了很多次。
I have a custom styled Combobox which works fine. It is placed inside a usercontrol and bound to a data structure. I use DisplayMemberPath to show only one element in the Combobox TextBox. The ComboBox Style is taken from MSDN and used many times. So it's not displayed here.
<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
我收到以下恼人的错误消息填充输出窗口:
I get the following annoying error message populating the output window:
System.Windows.Data Error: 25 : Both 'ContentTemplate' and 'ContentTemplateSelector' are set; 'ContentTemplateSelector' will be ignored. ComboBoxItem:'ComboBoxItem' (Name='')
如果我省略了
if i leave out the
DisplayMemberPath="Name"
...没有显示关于错误25的调试输出。但我肯定需要DiplayMemberPath =名称!
你有想法来解决这个问题吗?
... no debug output about error 25 is shown. But I definitely need DiplayMemberPath="Name"! Do You have an idea to fix this ?
推荐答案
解决:使用TextSearch附加属性,无论TextSearch已启用!
resolved: use the TextSearch attached property, no matter if TextSearch is enabled!
TextSearch.TextPath="Name"
这篇关于wpf调试错误输出System.WIndows.Data错误25的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!