我有一个列表框项目的以下数据模板:
<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
任何帮助都将不胜感激。
答案 0 :(得分:1)
您向ItemsPanelTemplate
添加了ListBox
,您的定义缺少ListBox.ItemsPanel
代码来设置属性。