Binding a List<List<Object>> to Datagrid.

Mar 20, 2009 at 3:42 PM

I have a situation where I have to bind a List<List<Object>> with a WPF Toolkit datagrid. In each object I have a property by the name of "Value" whose data I want to display within the grid.

I have tried this but the grid does not generate properly. Can someone please advice me on a way to achive this.

Apr 7, 2009 at 2:22 PM
Hi There,

I have the same requirement...

Has anybody acomplished this already? Automaticaly binding to a List<List<double>>?

Thanks in advance
Apr 7, 2009 at 5:20 PM
A WPF datagrid cannot be directly bound to a data grid. You will need to bind the grid in your code behind.

And create the grid based on the data.
Apr 7, 2009 at 5:59 PM
Thank you for your input..

Do you know of any of those workarounds (code examples would be great)?

Thanks in advance
Apr 7, 2009 at 6:29 PM
As already suggested, you can solve this by manually setting up the bindings in code. I do this for a list of objects with several fields I want to display in a single row in my grid. However, there may be some issues with how the columns bindings are cleared. See my other post on manually creating and clearing bindings for example code. 

If you have a list, you will need to use the array syntax.

DataGridTextColumn newColumn = new DataGridTextColumn();
newColumn.Binding = new Binding("MyPath");

Where MyPath is of the form "MyOuterList[ListIndex].ProperyNameOrValue", and is a string.

Hope this helps,