有人可以帮助我理解为 TreeView 组件和模型创建 xaml 代码的方法,如下所示:
class Task: ObservableObject
{
private string _title;
public string Title {
get { return _title; }
set {
if (value != _title) {
_title = value;
OnPropertyChanged("Title");
}
}
}
public override string ToString() {
return Title;
}
}
class Tasks:ObservableCollection<Task>
{
}
class Group:ObservableObject
{
private Tasks _tasksList;
public Group() {
_tasksList = new Tasks();
}
public Tasks TasksList {
get{
return _tasksList;
}
set {
if (value != _tasksList) {
_tasksList = value;
OnPropertyChanged("TasksList");
}
}
}
}
class Groups:ObservableCollection<Group>
{
}
我想要的只是使用 TreeView 组件和数据查看
Group1
Task 1
Task 2
Group2
Task 3
Task 4
使用 InputSource 和 DataContext ...