I am trying to populate a WPF datagrid but it's only showing the column headers and the content cells of the first(!) column. All other cells are empty:
The DataGrid is defined like this:
<DataGrid ItemsSource="{Binding Classifications, Mode=OneWay}"
AutoGenerateColumns="True" HeadersVisibility="Column" />
Classifications is defined in the code-behind file like this:
public DataView Classifications
{
get
{
return ClassificationDataTable.GetTable(myData).DefaultView
}
}
and finally this is my data generator:
public static class ClassificationDataTable
{
public static DataTable GetTable(List<Classification> classifications)
{
DataTable table = new DataTable();
// build columns
table.Columns.Add("FruitPrototype", typeof (string));
foreach (var featureComparison in classifications[0].FeatureComparisons)
table.Columns.Add(featureComparison.FeatureName, typeof (double));
// add rows
foreach (var classification in classifications)
{
object[] values = new object[classification.FeatureComparisons.Count+1];
values[0] = classification.FruitPrototype.FruitType;
for (int i = 0; i < classification.FeatureComparisons.Count; i++)
values[i + 1] = classification.FeatureComparisons[i].NormalizedDistance;
table.Rows.Add(values);
}
return table;
}
}
I verified the binding and can confirm that the DefaultView of the DataTable is indeed bound to the ItemsSource of my DataGrid. Also, the double values that should be shown in the grid are != 0.
What am I missing here?