Skip to content

Commit afe9287

Browse files
Update ViewModel.cs
1 parent b8a4ae6 commit afe9287

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

CS/HierarchicalDataTemplate/ViewModel.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.Generic;
2+
using System.Collections.ObjectModel;
23

34
namespace HierarchicalDataTemplate {
45

@@ -10,22 +11,22 @@ public ViewModel() {
1011
}
1112
}
1213
public class Data {
13-
public List<Category> Categories { get; set; }
14+
public ObservableCollection<Category> Categories { get; set; }
1415
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>();
1718
subitems.Add(new Item() { ItemName = "Chair", Description = "A red chair." });
1819
subitems.Add(new Item() { ItemName = "Table", Description = "An old table." });
1920
Categories.Add(new Category() { CategoryName = "Furniture", Items = subitems });
20-
List<Item> books = new List<Item>();
21+
ObservableCollection<Item> books = new ObservableCollection<Item>();
2122
books.Add(new Item() { ItemName = "Dictionary", Description = "My old French-English Dictionary" });
2223
Categories.Add(new Category() { CategoryName = "Books", Items = books });
2324
}
2425
}
2526
public class Category {
2627
public string CategoryName { get; set; }
2728
public string Description { get; set; }
28-
public List<Item> Items { get; set; }
29+
public ObservableCollection<Item> Items { get; set; }
2930
}
3031
public class Item {
3132
public string ItemName { get; set; }

0 commit comments

Comments
 (0)