2012-11-20 70 views
0

結合有人可以幫助我理解的方式FO的樹視圖組件和模型像這樣的創建XAML代碼:TreeView的數據在C#/ WPF

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> 
{ 

} 

所有我想要的查看與樹視圖組件和數據,如

Group1 
    Task 1 
    Task 2 
Group2 
    Task 3 
    Task 4 

使用的InputSource和DataContext的...

回答