【问题标题】:DataTemplate for Listbox containing lists as items doesn't get displayed包含列表作为项目的列表框的 DataTemplate 不会显示
【发布时间】:2012-02-09 23:40:43
【问题描述】:

我有以下列表框项目的数据模板:

<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

任何帮助将不胜感激。

【问题讨论】:

    标签: wpf listbox datatemplate stackpanel itemtemplate


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2012-01-19
      • 1970-01-01
      • 1970-01-01
      • 2016-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多