2012-02-09 79 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標籤來設置屬性。