C#WPF listview不更新

C#WPF listview不更新,c#,wpf,listview,C#,Wpf,Listview,列名显示在listview中,但行不显示。 所以我认为这部分是正确的: List<string[]> list = gl.ReadCSV(fileNameBox.Text); GridView gridView = new GridView(); listViewTable.View = gridView; foreach (string st in list.First()) { gridView.Columns.Add(new GridViewColumn {

列名显示在listview中,但行不显示。 所以我认为这部分是正确的:

List<string[]> list = gl.ReadCSV(fileNameBox.Text);

GridView gridView = new GridView();
listViewTable.View = gridView;
foreach (string st in list.First())
{
     gridView.Columns.Add(new GridViewColumn
    {
        Header = st,
        DisplayMemberBinding = new Binding(st)
    });
}
  • 您需要在FHFInfo类中具有名称与CSV文件头完全相同的属性
  • 这些财产必须公开

  • 您确定list.Count>1吗?问题是行是空的还是listview是空的?请向我们展示FHFInfo类,该类应具有属性,这些属性的名称与headersI以1开头的名称完全相同,因为第一行(0)中是列的名称。行是空的,当我调试时,我可以看到listview.Items.Add()添加了所有内容,但在GUI中listview保持为空。(除了列名)那么你能不能显示为FHFInfo类?你是否试图公开你的财产?
    for (int i = 1; i < list.Count; i++)
    {
        listViewTable.Items.Add(new FHInfo(list[i][0], list[i][1], list[i][2], list[i][3], list[i][4], 
                        list[i][5], list[i][6], list[i][7], list[i][8], list[i][9], list[i][10], list[i][11], list[i][12]));
    }
    listViewTable.Items.Refresh();
    
    class FHInfo
    {
        private string building;
        private string floor;
        private string room;
        private string roomdesc;
        private string distributor;
        private string patchpanel;
        private string socket;
        private string switchFH;
        private string lineCard;
        private string port;
        private string vlan;
        private string device;
        private string gigabitAble;
    
        internal string Building { get => building; set => building = value; }
        internal string Floor { get => floor; set => floor = value; }
        internal string Room { get => room; set => room = value; }
        internal string Roomdesc { get => roomdesc; set => roomdesc = value; }
        internal string Distributor { get => distributor; set => distributor = value; }
        internal string Patchpanel { get => patchpanel; set => patchpanel = value; }
        internal string Socket { get => socket; set => socket = value; }
        internal string SwitchFH { get => switchFH; set => switchFH = value; }
        internal string LineCard { get => lineCard; set => lineCard = value; }
        internal string Port { get => port; set => port = value; }
        internal string Vlan { get => vlan; set => vlan = value; }
        internal string Device { get => device; set => device = value; }
        internal string GigabitAble { get => gigabitAble; set => gigabitAble = value; }
    
        public FHInfo(string building, string floor, string room, string roomdesc, string distributor, string patchpanel, string socket, string switchFH, string lineCard, string port, string vlan, string device, string gigabitAble)
        {
            this.building = building;
            this.floor = floor;
            this.room = room;
            this.roomdesc = roomdesc;
            this.distributor = distributor;
            this.patchpanel = patchpanel;
            this.socket = socket;
            this.switchFH = switchFH;
            this.lineCard = lineCard;
            this.port = port;
            this.vlan = vlan;
            this.device = device;
            this.gigabitAble = gigabitAble;
        }
    }