Master
Master

Reputation: 2153

Display Multiple Member Path for Listbox

I'm binding the ItemsSource of my Listbox to list of Event class. Event has the following properties:

Date
Title
Company
Description

I can Currently Display any 1 of those properties using the line below:

<ListBox ItemsSource="{Binding FilteredEventsCollection}" DisplayMemberPath="Date"/>

I want to display all the information, May I ask how do I do that?

Upvotes: 3

Views: 1361

Answers (1)

Sajeetharan
Sajeetharan

Reputation: 222592

Make use of Data Template to Display various properties inside different controls inside listbox

<ListBox ItemsSource="{Binding FilteredEventsCollection}">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <StackPanel>
                <TextBlock Text="{Binding Date}" />
                <TextBlock Text="{Binding Title}" />
                <TextBlock Text="{Binding Company}" />
                <TextBlock Text="{Binding Description}" />
            </StackPanel>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

Upvotes: 7

Related Questions