1
1
using System . Collections . Generic ;
2
+ using System . Collections . ObjectModel ;
2
3
3
4
namespace HierarchicalDataTemplate {
4
5
@@ -10,22 +11,22 @@ public ViewModel() {
10
11
}
11
12
}
12
13
public class Data {
13
- public List < Category > Categories { get ; set ; }
14
+ public ObservableCollection < Category > Categories { get ; set ; }
14
15
public Data ( ) {
15
- Categories = new List < Category > ( ) ;
16
- List < Item > subitems = new List < Item > ( ) ;
16
+ Categories = new ObservableCollection < Category > ( ) ;
17
+ ObservableCollection < Item > subitems = new ObservableCollection < Item > ( ) ;
17
18
subitems . Add ( new Item ( ) { ItemName = "Chair" , Description = "A red chair." } ) ;
18
19
subitems . Add ( new Item ( ) { ItemName = "Table" , Description = "An old table." } ) ;
19
20
Categories . Add ( new Category ( ) { CategoryName = "Furniture" , Items = subitems } ) ;
20
- List < Item > books = new List < Item > ( ) ;
21
+ ObservableCollection < Item > books = new ObservableCollection < Item > ( ) ;
21
22
books . Add ( new Item ( ) { ItemName = "Dictionary" , Description = "My old French-English Dictionary" } ) ;
22
23
Categories . Add ( new Category ( ) { CategoryName = "Books" , Items = books } ) ;
23
24
}
24
25
}
25
26
public class Category {
26
27
public string CategoryName { get ; set ; }
27
28
public string Description { get ; set ; }
28
- public List < Item > Items { get ; set ; }
29
+ public ObservableCollection < Item > Items { get ; set ; }
29
30
}
30
31
public class Item {
31
32
public string ItemName { get ; set ; }
0 commit comments