user565660
user565660

Reputation: 1191

Binding a collection to a list box

I have an object called TheObject. Each 'TheObject' contains attribute A,B, and C.

I also have a collection of 'TheObject's ObservalbeCollection TheCollection

I want to bind this collection to a ListView so that it displays Coloum A, Column B, Column C across the screen.

So the list would resemble :

TheCollection[1].A TheCollection[1].B TheCollection[1].C

TheCollection[2].A TheCollection[2].B TheCollection[2].C etc.

what is the simplest way to bind the listview???

Thank you very,much

Upvotes: 0

Views: 135

Answers (1)

brunnerh
brunnerh

Reputation: 184296

This:

<ListView ItemsSource="{Binding MyCollection}">
    <ListView.View>
        <GridView>
            <GridViewColumn DisplayMemberBinding="{Binding A}"/>
            <GridViewColumn DisplayMemberBinding="{Binding B}"/>
            <GridViewColumn DisplayMemberBinding="{Binding C}"/>
        </GridView>
    </ListView.View>
</ListView>

[Binding basics]

Upvotes: 2

Related Questions