-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathViewModel.vb
47 lines (32 loc) · 1.49 KB
/
ViewModel.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Imports System.Collections.ObjectModel
Namespace HierarchicalDataTemplate
Public Class ViewModel
Public Property MyData As Data
Public Property SelectedItem As Object
Public Sub New()
MyData = New Data()
End Sub
End Class
Public Class Data
Public Property Categories As ObservableCollection(Of Category)
Public Sub New()
Categories = New ObservableCollection(Of Category)()
Dim subitems As ObservableCollection(Of Item) = New ObservableCollection(Of Item)()
subitems.Add(New Item() With {.ItemName = "Chair", .Description = "A red chair."})
subitems.Add(New Item() With {.ItemName = "Table", .Description = "An old table."})
Categories.Add(New Category() With {.CategoryName = "Furniture", .Items = subitems})
Dim books As ObservableCollection(Of Item) = New ObservableCollection(Of Item)()
books.Add(New Item() With {.ItemName = "Dictionary", .Description = "My old French-English Dictionary"})
Categories.Add(New Category() With {.CategoryName = "Books", .Items = books})
End Sub
End Class
Public Class Category
Public Property CategoryName As String
Public Property Description As String
Public Property Items As ObservableCollection(Of Item)
End Class
Public Class Item
Public Property ItemName As String
Public Property Description As String
End Class
End Namespace