将 DataTable 绑定到 DataGrid 显示空行

Binding a DataTable to a DataGrid shows empty rows

我想将数据表绑定到 wpf 中的数据网格。此数据网格显示列 header 正确,行数正确,但行为空。

当我调试我的数据表时(使用那个:)我有一个正确的数据表:

--- DebugTable() ---
07/08/2014           | 
---------------------|-
0,0186               | 
0,035                | 
---------------------|-

我的数据网格有正确的 header“07/08/2014”和 2 个空行。

这是我的 DataGrid Xaml:

<DataGrid AutoGenerateColumns="true" ItemsSource="{Binding Table}"></DataGrid>

我错过了什么?

更新: 我在输出中看到了:

System.Windows.Data Error: 40 : BindingExpression path error: '07' property not found on 'object' ''DataRowView' (HashCode=32322646)'. BindingExpression:Path=07/08/2014; DataItem='DataRowView' (HashCode=32322646); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')

可能是制作数据表时出错了?

public DataTable Table { get { return this.GetTable(); } }

private DataTable GetTable()
{
    DataTable table = new DataTable();
    foreach (var controle in Controles)
    {
        table.Columns.Add(new DataColumn(controle.Date.ToShortDateString()));
    }
    DataRow rowMoyenne = table.NewRow();
    DataRow rowEtendue = table.NewRow();
    for (int i = 0; i < table.Columns.Count; i++)
    {
        DataColumn column = table.Columns[i];
        rowMoyenne[column] = Controles[i].Moyenne.ToString();
        rowEtendue[column] = Controles[i].Etendue.ToString();
    }
    table.Rows.Add(rowMoyenne);
    table.Rows.Add(rowEtendue);
    return table;
}

问题是字符:“/”

What is it about DataTable Column Names with dots that makes them unsuitable for WPF's DataGrid control?

感谢您的帮助。