有人可以帮助我理解为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>
{
}
我想拥有的是View with TreeView组件和数据,如
Group1
Task 1
Task 2
Group2
Task 3
Task 4
使用InputSource和DataContext ...