【发布时间】:2018-12-09 06:18:52
【问题描述】:
我在 wpf 中遇到了 DataGrid 的问题
这是一个类:
class Superviser
{
public long Id = 0;
public string name = "";
public string father = "";
public string code = "";
}
这是一个构建此类对象列表的函数
public List<Superviser> allSuperviser()
{
return db.tbPersons.Where(i => i.level == StaticsObject.isSuperviser).Select(x => new Superviser
{
Id = x.Id,
name = x.firstName,
father = x.father,
code = x.code,
}).ToList();
}
我使用此代码在 datagrid 中设置此列表
dgvPerson.ItemsSource = classPerson.allSuperviser();
但是运行程序时datagrid是空的!
提示:列表不为空。
问题出在哪里?
如何在 DataGrid 上显示此列表?
【问题讨论】:
标签: list class object datagrid itemsource