major edit of a tumbleweed, may remain a tumbleweed...
If I have a list of Customers and the data for each Customer is contained in a Dictionary how can I bind the list to the DataGrid so that each string key is a column?
Edit: N.B. I know it's not a nice way to design a Customer class.
e.g.
public class Customer{
public int Id{get;set;}
private Dictionary<string,string> values;
public Dictionary<string,string> Values{get {return values;}}
public Customer(int id){
this.Id = id;
values["Name"] = "Peter";
values["Age"] = 129.ToString();
values["HairColour"] = "See through!";
}
}
... later that day...
var Customers = new List<Customer>(){
new Customer(1),
new Customer(2),
new Customer(3)
};
... and then...
<DataGrid ItemsSource={Binding Path=Customers}/>
... desired result.
Id | Name | Age | HairColour
________________________
1 | Peter| 129 | See through!
________________________
2 | Peter| 129 | See through!
________________________
3 | Peter| 129 | See through!
________________________