为什么 DataGrid 在 DataGrid.Items.Add 上添加空元素?

Why DataGrid adds empy elements on DataGrid.Items.Add?

在我需要的 WPF 中,然后我单击按钮,将包含信息的新行添加到 DataGrid。但是当我按下按钮时,新行正在创建,但它的填充是空的,没有任何字符串。如何解决?感谢提前。

XAML 代码:

<DataGrid Name="ClicksGrid" HorizontalAlignment="Left" Height="204" Margin="348,20,0,0" AutoGenerateColumns="False" CanUserAddRows="True" VerticalAlignment="Top" Width="354">
            <DataGrid.Columns>
                <DataGridTextColumn Header="ID" IsReadOnly="True" Binding="{Binding Path=ID}" Width="40" />
                <DataGridTextColumn Header="ClickType" IsReadOnly="True" Binding="{Binding Path=Type}" Width="120" />
                <DataGridTextColumn Header="Time" IsReadOnly="True" Binding="{Binding Path=Time}" Width="193"/>
            </DataGrid.Columns>
        </DataGrid>

c#代码:

// click class 
public class Click
    {
        public string ID;
        public string Type;
        public string Time;

        public Click(string ID, string Type, string Time)
        {
            this.ID = ID;
            this.Type = Type;
            this.Time = Time;
        }
    }


// by button clicking calling this method:

 private void TableUpdate()
        {
            IDnum++;

            //test strings:
            var cl = new Click("asd", "sdad", "asds");


            ClicksGrid.Items.Add(cl);   
        }

更改点击class这样:

    public class Click
    {
        public string ID { get; set; }
        public string Type { get; set; }
        public string Time { get; set; }

        public Click(string ID, string Type, string Time)
        {
            this.ID = ID;
            this.Type = Type;
            this.Time = Time;
        }
    }