包含列表作为项目的Listbox的DataTemplate不显示 [英] DataTemplate for Listbox containing lists as items doesn't get displayed
本文介绍了包含列表作为项目的Listbox的DataTemplate不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
对于列表框项目,我具有以下数据模板:
I have the following data template for a list box items:
<DataTemplate x:Key="substanceListShower">
<ListBox ItemsSource="{Binding Items}">
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox>
</DataTemplate>
然后我像这样应用项目模板:
And then I apply the item template like this:
ReactantInterfacesListBox.ItemTemplate = (DataTemplate)FindResource("substanceListShower");
但是在项目列表中,我得到了ToString()返回:
But in the list for the items i get a ToString() return:
System.Windows.Controls.ItemsPanelTemplate
任何帮助将不胜感激.
推荐答案
您在ListBox
中添加ItemsPanelTemplate
,但定义中缺少ListBox.ItemsPanel
标记来设置属性.
You add an ItemsPanelTemplate
to your ListBox
, your definition lacks the ListBox.ItemsPanel
tags to set the property instead.
这篇关于包含列表作为项目的Listbox的DataTemplate不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文