包含列表作为项目的列表框的 DataTemplate 不会显示
我有以下列表框项目的数据模板:
<DataTemplate x:Key="substanceListShower">
<ListBox ItemsSource="{Binding Items}">
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox>
</DataTemplate>
然后我像这样应用项目模板:
ReactantInterfacesListBox.ItemTemplate = (DataTemplate)FindResource("substanceListShower");
但是在项目列表中我得到 ToString() 返回:
System.Windows.Controls.ItemsPanelTemplate
如有任何帮助,我们将不胜感激。
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");
But in the list for the items i get a ToString() return:
System.Windows.Controls.ItemsPanelTemplate
Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将
ItemsPanelTemplate
添加到ListBox
中,但您的定义缺少用于设置属性的ListBox.ItemsPanel
标记。You add an
ItemsPanelTemplate
to yourListBox
, your definition lacks theListBox.ItemsPanel
tags to set the property instead.