我正在尝试TreeView使用数据模板将集合绑定到wpf 控件.集合中的每个项目(人物)还包含两种不同的汽车和书籍集合(汽车,书籍).
这是节省空间所涉及的对象的简化列表.
public class Person
{
public string Name
public List<Book> Books;
public List<Car> Cars;
}
public class Book
{
public string Title
public string Author
}
public class Car
{
public string Manufacturer;
public string Model;
}
Run Code Online (Sandbox Code Playgroud)
这就是我的约束力
public MainWindow()
{
InitializeComponent();
this.treeView1.ItemsSource = this.PersonList();
}
public List<Person> PersonList()
{
List<Person> list = new List<Person>();
Book eco = new Book { Title = "Economics 101", Author = "Adam Smith"};
Book design = new Book { Title …Run Code Online (Sandbox Code Playgroud)