mihajlv
mihajlv

Reputation: 2315

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

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.

Upvotes: 0

Views: 223

Answers (1)

brunnerh
brunnerh

Reputation: 184296

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

Upvotes: 1

Related Questions