wpf调试错误输出System.WIndows.Data错误25
发布时间:2020-12-14 04:20:29 所属栏目:Windows 来源:网络整理
导读:我有一个定制风格的Combobox工作正常.它放在usercontrol中并绑定到数据结构.我使用DisplayMemberPath只显示Combobox TextBox中的一个元素. ComboBox样式取自MSDN并多次使用.所以这里没有显示. UserControl x:Class="wpf.projext1.MyComboBox" x:Name="MyCont
我有一个定制风格的Combobox工作正常.它放在usercontrol中并绑定到数据结构.我使用DisplayMemberPath只显示Combobox TextBox中的一个元素. ComboBox样式取自MSDN并多次使用.所以这里没有显示.
<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 =“名字”!
您不能同时设置DisplayMemberPath和ItemTemplate.
DisplayMemberPath用于告诉ItemsControl在显示对象时要显示的属性.如果您已经传递了自定义ItemTemplate,那么设置此字段就没有了,因为您可以选择如何在该ItemTemplate中显示该对象. 由于MSDN的默认Combobox样式也设置了ItemTemplate,这可能是导致错误的原因. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Windows 2012 R2启动按钮无法通过RDP工作
- windows-server-2003 – 如何审核文件以查看谁删除了文件?
- DirectX11 With Windows SDK--18 使用DirectXCollision库进
- .net – System.Serializable属性在Windows 10的UWP应用程序
- qt – 如何禁用调整大小光标
- Windws Server 2008 R2 WEB环境配置之IIS7/IIS7.5+FastCGI+
- 如何在Windows上使用提升的权限运行.msi安装程序
- windows-server-2008 – 云中的Active Directory
- beyond compare 过期解决方法
- 在Windows上使用SVN自动部署?
推荐文章
站长推荐
热点阅读