views:

269

answers:

4

Hi,

I have two observeable collection both set to a class of properties. I am needing to combine both of those collections into one listbox. I have looked up at the Compositecollection class but it is not what I need. Ideally, I want the listbox to look like this...

Think of this as a listbox control and each listbox item contains objects from the source properties of two observeable collection.

Collection1 Collection1
--------------------------
Data          Data
--------------------------
Data          Data
--------------------------
Data          Data
--------------------------
Data          Data
--------------------------
Data          Data
--------------------------

I am just wondering if it will actually be possible to do something like that?

A: 

If I understand you correctly, then no. ListBox can only bind to one source. What you could do is combine both collection into one, then use a multibinding to show both sets of data on each line.

McAravey
+1  A: 

Well if I got your question right,

you can create a another collection (say a List) where each element would be an anonymous type (or a type depends on what you want as a DisplayMember and ValueMember) composed of each element of Collection1 and Collection2.

AB Kolan
A: 

If I understood your question correctly, you should be able to do that by using a Linq Join

Thomas Levesque
A: 

You can use MultiBinding and define a converter that will join the two (or more) collections into one.

Captain