DataTemplate for Listbox containing lists as items doesn't get displayed

て烟熏妆下的殇ゞ 提交于 2019-12-12 02:58:39

问题


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.


回答1:


You add an ItemsPanelTemplate to your ListBox, your definition lacks the ListBox.ItemsPanel tags to set the property instead.



来源:https://stackoverflow.com/questions/9220702/datatemplate-for-listbox-containing-lists-as-items-doesnt-get-displayed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!