-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainViewModel.vb
83 lines (62 loc) · 2.29 KB
/
MainViewModel.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
Imports DevExpress.Mvvm
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
Namespace MultiLevelMasterDetail
Public Class MainViewModel
Inherits ViewModelBase
Private _Items As ObservableCollection(Of MultiLevelMasterDetail.MasterLevelItem)
Public Sub New()
Items = New ObservableCollection(Of MasterLevelItem)()
InitMasterItems()
CurrentMasterItem = Nothing
End Sub
Public Property Items As ObservableCollection(Of MasterLevelItem)
Get
Return _Items
End Get
Private Set(ByVal value As ObservableCollection(Of MasterLevelItem))
_Items = value
End Set
End Property
Public Property CurrentMasterItem As MasterLevelItem
Get
Return GetValue(Of MasterLevelItem)()
End Get
Set(ByVal value As MasterLevelItem)
SetValue(value)
End Set
End Property
Public Property CurrentDetailItem As DetailLevelItem
Get
Return GetValue(Of DetailLevelItem)()
End Get
Set(ByVal value As DetailLevelItem)
SetValue(value)
End Set
End Property
Private Sub InitMasterItems()
For i As Integer = 0 To 10 - 1
Items.Add(New MasterLevelItem() With {.MasterId = i, .MasterName = String.Format("master item {0}", i)})
Next
End Sub
End Class
Public Class MasterLevelItem
Public Property MasterId As Integer
Public Property MasterName As String
Public Property DetailItems As List(Of DetailLevelItem)
Public Sub New()
DetailItems = New List(Of DetailLevelItem)()
InitDetailItems()
End Sub
Private Sub InitDetailItems()
For i As Integer = 0 To 10 - 1
DetailItems.Add(New DetailLevelItem() With {.DetailId = i, .DetailName = String.Format("detail item {0}", i), .MasterItem = Me})
Next
End Sub
End Class
Public Class DetailLevelItem
Public Property DetailId As Integer
Public Property DetailName As String
Public Property MasterItem As Object
End Class
End Namespace