Let's assume there is the following class (for example purposes):
public class Item
{
public String Key {get;set;}
public String[] Values { get; set;}
}
for making it simple, imagine the length of each "Item"'s "Values" array is the same. Let's have a collection of these "Item"s:
ExampleA:
List<Item> items = new List<Items>(
new Item() { Key = "A", Values = new String[]{"OneA", null, "ThreeA"}},
new Item() { Key = "B", Values = new String[]{"OneB", "TwoB", null}},
new Item() { Key = "C", Values = new String[]{null, null, "ThreeC"}}
);
ExampleB:
List<Item> items = new List<Items>(
new Item() { Key = "1", Values = new String[]{"One1", null}},
new Item() { Key = "2", Values = new String[]{"One2", "Two2"}},
new Item() { Key = "3", Values = new String[]{null, null}}
);
So how could I make a DataGrid
from the ToolKit having the following columsn in the next cases:
ExampleA:
A | OneA | ____ | ThreeA |
B | OneB | TwoB | ______ |
C | ____ | ____ | ThreeC |
ExampleB:
1 | OneA | ____ |
2 | OneB | TwoB |
3 | ____ | ____ |
So, in words: in different cases the Values arrays have different length. But for one case all the Values arrays have the same length (for simplification).
If DataGridInstance.ItemsSource
is bound to items (NotifyPropertyChanged
is implemented), how would the columns are set and how would the binding of the column values are set?
Of course at every refresh DataGridInstance.Columns.Clear()
is said.
Than the columns are added again, the amount of them is well known (depends on the length of the "Values" array of course).
But how I would create the binding of the values?
I'd like to have something like the following:
Binding columnABinding = new Binding("Values[0]");
Binding columnBBinding = new Binding("Values[1]");
Binding columnCBinding = new Binding("Values[3]");
Uh, sorry for my bad english. I tried to keep it simple, hope it is understandable! Thank you for your answers in advance!