2012-02-09 38 views
0

我有一个列表框项目的下列数据模板: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

任何帮助,将不胜感激。

回答

1

您将ItemsPanelTemplate添加到您的ListBox,您的定义中缺少ListBox.ItemsPanel标签来设置属性。