0

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

2
  • ok then what have you got so far and were are is the question? Commented Apr 29, 2011 at 11:30
  • Well, I have not really an idea how to begin. Commented Apr 29, 2011 at 11:33

1 Answer 1

1

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 :)

Sign up to request clarification or add additional context in comments.

1 Comment

In XAML you can do static things rather well. For trickery like this I would recommend to use codebehind. Just because it's more compact. There's nothing wrong with that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.