0
votes

I have a problem at binding data to the WPF DataGrid.

There is a class like (simplified):

public ClassToShow
{
    public int ANumber {get; set;}
    public List<bool> TheList {get; set;}
}

and now I need a Datagrid showing these Data. TheList has the same number of elements in each object for the grid.

So there should be

ANumber | TheList[o] | TheList [1] | ...

I tried a lot... at last DataGridTemplateColumn with a Listbox in, but how to set the header then?!?


In real is more like that:

public class ClassToShow
{
    public int row {get; set;}
    public List<CheckBoxElement> Cl{get; set;}
    public List<TextBoxElement> Tl{get; set;}
    public List<string> Steps {get; set;}
}

with public class CheckBoxElement { public string Name {get; set;} public bool Value {get; set; } }

and public class TextBoxElement { public string Name {get; set;} public int Value {get; set;} }

Then there is a List with an state for each value in Cl and Tl.

As result I need a DataGrid like this: (First row is the Header, second comes from the bool-list the elements to show starts at row three.

   | Cl[0].Name | Cl[1].Name |...| Tl[0].Name |...| Step
--------------------------------------------------------------
   | Checkbox   | Checkbox   |...| Checkbox   |...|
--------------------------------------------------------------
1  | Checkbox   | Checkbox   |...| Textbox    |...| Combobox
2  | ...
....
1

1 Answers

0
votes

It can be made by a template: make a template for the headline of the datagrid and put the checkboxes (or whatever you need) in there.