【发布时间】:2018-12-08 04:22:06
【问题描述】:
我的wpf app xaml很简单,只有一个datagrid:
<DataGrid ItemsSource="{Binding UserCollection}"/>
在后面的代码中,UserCollection 是一个 DataTable:
private DataTable userCollection;
public DataTable UserCollection
{
get { return this.userCollection; }
set
{
this.userCollection = value;
NotifyPropertyChanged();
}
}
在 ViewModel.cs 中,代码很简单,创建 2 列并添加一行:
this.UserCollection = new DataTable();
UserCollection.Columns.Add("col1", typeof(int));
UserCollection.Columns.Add("co.l2", typeof(int));
var r=UserCollection.NewRow();
r["col1"] = 1;
r["co.l2"] = 2;
UserCollection.Rows.Add(r);
但是听者中包含点的第二列无法在UI中显示该值,您可以看到图片。
为什么?
【问题讨论】: