I’m trying to bind a List<List<string>> to a DataGrid programatically. I’m using
this List<List<string>> because the DataGrid has to have a variable number of columns.
Actually, I got to bind the DataGrid to an string[][] but it is partially useful because there will be the need to get this data structure and add rows to it, that’s why I want to use a List<List<string>>.
Currently, I’m using this snippet to generate the columns.
dgResults.Columns.Clear();
for (int i = 0; i < numColumns; i++)
{
DataGridTextColumn textColumn = new DataGridTextColumn();
textColumn.Binding = new Binding(string.Format("[{0}]", i));
dgResults.Columns.Add(textColumn);
}
What should I use on textColumn.Binding in order to bind to a List<list<string>>?
Wow… I was using the
string[][]structure… but with the snippet I wrote,List<List<string>>can be used to the intended purpose!