WPF C# DataGrid Binding to Complex ViewModel

  Uncategorised

I’ve been struggling quite some time now and I just cannot seem to succeed. Can anyone help me how to accomplish the following:

  • There is a main data grid/row (holds title, date values and location for instance: New York)
  • Within this data grid/row, there must be a solution where I have three columns (while being within the first row still): 1. column shows a collection of Person, 2. column shows a collection of Animal and 3. column just shows some description text. All this information should be displayed within the same row.
  • Also the data grid should be expandable/collapsible.. so if u click on the first row, it should display the child items of collections: person, animal and the description.

I’ve been trying and trying.. and just can’t try to make this work.. I found an example solution, but that just works for a type of X, while I have multiple collections within the same viewmodel I want and these collections should be displayed within the same row within the parent..
Here is what I had found that comes near to my solution, but couldn’t make it work for my problem:
Check: "Yong Lu Wicresoft(MSFT CSG)" solution

I’ve also tried multi binding, but either I don’t know how this exactly works or it didn’t work either:
Multi binding

So to summarize it: I have a ViewModel where there is a initial collection of type Environment (IList), then I have other properties like IList and IList and as for the last, there is a string property called Text.. Now I want to use the collection of environment for the first row and when I expand the first row by clicking, it should expand child collections within the same row from left to right where I see a list of persons, animals and just one text within a cell.. I just don’t know how to make this work and really having a hard time here..

Can someone please help me with this.. Thank you for your effort in advance.

Source: Visual Studio Questions

LEAVE A COMMENT