Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying many-to-many groupings in WPF

I'm not sure if i'm on the right track with this one, but essentially I'm trying to display a grouped list of items, where each item can be a member of multiple groups. i.e. The two entities are related on a many-to-many basis. I'll try to explain...


enter image description here


enter image description here


My question is, how do I group items like this into a control? I'm aware of the ICollectionView and the PropertyGroupDescription, but that doesn't seem to serve my purpose here (it seems to only work in a one-to-many scenario).

Any ideas?

Some points to note:

  1. When displayed in a list, I want to show all Component's grouped by Kit.
  2. When I select a component from this list, I only want that particular instance of the Component (i.e. I want Component + the Kit I selected it from).
  3. Ignore the fact that i'm using a TreeView to show the items below, as i'll actually be using a ListBox with a GroupStyle
  4. I'm using code-first EF 4.3.1 and the WPF MVVM pattern.
like image 937
mortware Avatar asked Jun 07 '12 11:06

mortware


1 Answers

Use the Include() method on the context object to include the related entities.

like image 109
Brendon Bezuidenhout Avatar answered Sep 28 '22 09:09

Brendon Bezuidenhout