ObservableCollection<T> 类
命名空间: System.Collections.ObjectModel
程序集: System(在 System.dll 中)
XAML 的 XMLNS: 未映射到 xmlns。
添加:using System.Collections.ObjectModel;
ObservableCollection<Persons> persons = new ObservableCollection<Persons> { new Persons { CurrPerson = new List<Person> { new Person{Name="姓名1", Age=21}, new Person{Name="姓名2", Age=23} } }, new Persons { CurrPerson = new List<Person> { new Person{Name="姓名4", Age=21}, new Person{Name="姓名5", Age=23} } } };
作为数据源:
list1.ItemsSource = persons;
定义类:
class Person { public string Name { get; set; } public int Age { set; get; } public string Image { set; get; } public string Email { set; get; } } class Persons { public List<Person> CurrPerson { set; get; } }
"唯有高屋建瓴,方可水到渠成"