Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF: Listbox DisplayMember

Im using Listbox to present a table. It uses DisplayMemberPath to present items.

How can i do multi binding for displaying items?

Lets say i want to display ID and NAME ... is there a template example or such?

thnx

like image 401
no9 Avatar asked Sep 01 '26 07:09

no9


1 Answers

Use a DataTemplate.

Example:

<ListBox>
    <ListBox.ItemTemplate>
        <DataTemplate>
            <TextBlock>
                <TextBlock.Text>
                    <MultiBinding StringFormat="{}{0}, {1}">
                        <Binding Path="ID" />
                        <Binding Path="Name" />
                    </MultiBinding>
                </TextBlock.Text>
            </TextBlock>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>
like image 130
decyclone Avatar answered Sep 03 '26 21:09

decyclone



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!