WPF Listview Access to SelectedItem and subitems

后端 未结 3 2000
甜味超标
甜味超标 2020-12-07 00:30

Ok, I am having more problems with my C# WPF ListView control. Here it is in all its glory:



        
3条回答
  •  离开以前
    2020-12-07 01:28

        var items = from item in xdoc.Descendants("Book")
                select new Book()                                   //  <---
                {
                    ISBN = (string)item.Element("ISBN"),
                    Title = (string)item.Element("Title"),
                    Author = (string)item.Element("Author"),
                };
    
    foreach (var item in items)
    {
        listView1.Items.Add(item);
    }
    

    I have got an issue with code above, once I use it, my listView did not list any of those values. I do not know if that will help you or if that is correct but after a few tests I added () after "select new Book" and then ListView could show all fields correctly for me.

提交回复
热议问题