开发者

C# xaml datagrid binding 'list of a value'

Hi I use wpf and mvvm so the binding to my viewmodel is ok!

I have a class Question which has the property IEnumerable<Variation> Variations Variation has the property IEnumerable<<keyValuePair<QuestionParameter,string>>> QuestionParameters QuestionParameter has the property Name.

So let's say I have a datagrid with the Itemssource= SelectedQuestion.Variations

Now let's say I want this grid: qp = questionparamater en var = variation

Name questionpar1  | Name QuestionPar2  | Name QuestionPar3  | ...
stri开发者_运维问答ng qp1 of var1 | string qp2 of var1 | string qp3 of var1 | ...
string qp1 of var2 | string qp2 of var2 | string qp3 of var2 | ...
...

how do I do this?


the most easy way would be to create a flat collection with the structure you want. if QuestionParameters vary in ".Count"/are dynamic then its even harder :) i use a flat datatable for this tasks in my project, bause i can easily create columns dynamic.

i would say if you wanna use a datagrid you should create a flat collection.

i you want to use your dynamic collection you can use itemsscontrol datatemplates to create the output you want. the problem i see with this, is that you maybe have to sync the QuestionParameter for each item in Variations.

if QuestionParameter are not dynamic (e.g. fixed number: q1, q2,q3, q4), you can use a datagrid and a converter with convertparamter (QuestionParameter ) for displaying your results.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜