Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
List wpf数据网格集项源列表<;对象>;_List_Class_Object_Datagrid_Itemsource - Fatal编程技术网

List wpf数据网格集项源列表<;对象>;

List wpf数据网格集项源列表<;对象>;,list,class,object,datagrid,itemsource,List,Class,Object,Datagrid,Itemsource,我对wpf中的DataGrid有问题 这是一门课: class Superviser { public long Id = 0; public string name = ""; public string father = ""; public string code = ""; } 这是一个函数,用来建立这个类对象的列表 public List<Superviser> allSuperviser()

我对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为空时

提示:列表不是空的

问题在哪里


如何在DataGrid上显示此列表?你好,agian,我解决了它

我换了一个班:

class Superviser
{
    public long Id { get; set; }
    public string name { get; set; }
    public string father { get; set; }
    public string code { get; set; }
    public Superviser() { }

    public Superviser(long Id, string name, string father, string code)
    {
        this.Id = Id;
        this.name = name;
        this.father = father;
        this.code = code;
    }
}
并将功能更改为:

public List<Superviser> allSuperviser()
        {
            return db.tbPersons.Where(i => i.level == StaticsObject.isSuperviser).Select(x => new Superviser { Id = x.Id, name = x.firstName + " " + x.lastName, father = x.father, code = x.code }).ToList();
        }
public List allSuperviser()
{
返回db.tbPersons.Where(i=>i.level==StaticsObject.isSuperviser)。选择(x=>newsuperviser{Id=x.Id,name=x.firstName+“”+x.lastName,father=x.father,code=x.code})。ToList();
}
问题已经解决:)

public List<Superviser> allSuperviser()
        {
            return db.tbPersons.Where(i => i.level == StaticsObject.isSuperviser).Select(x => new Superviser { Id = x.Id, name = x.firstName + " " + x.lastName, father = x.father, code = x.code }).ToList();
        }