Reputation: 149
I want the following datagrid:
Name questionpar1 | Name QuestionPar2 | Name QuestionPar3 | ...
string qp1 of var1 | string qp2 of var1 | string qp3 of var1 | ...
string qp1 of var2 | string qp2 of var2 | string qp3 of var2 | ...
...
these are my classes:
Question with property IEnumerable<Variation> Variations
Variation with property IEnumerable<<keyValuePair<QuestionParameter,string>>> QuestionParameters
QuestionParameter has the property Name which is a string
Can Someone show me the code to make this datagrid?? I use MVVM so you can use: {Binding Path=}
thanks
Upvotes: 0
Views: 515
Reputation: 2380
This might work, not sure though:
var dataGrid = dataGridQuestions;
int i = 1;
foreach (var parameter in QuestionParameters)
{
var binding = new Binding("qp" + (i++).ToString());
binding.Mode = BindingMode.OneWay;
var column = DataGridTextColumn() { Binding = binding, Header=parameter.Value };
dataGrid.Columns.Add(column);
}
Good luck :)
Upvotes: 1