-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathEmployeesViewModel.vb
More file actions
65 lines (48 loc) · 2.07 KB
/
EmployeesViewModel.vb
File metadata and controls
65 lines (48 loc) · 2.07 KB
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
Imports DevExpress.Mvvm
Imports System.Collections
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
Imports System.Linq
Namespace ColumnsSample
Public Enum SettingsType
[Default]
Lookup
Binding
End Enum
Public Class ViewModel
Inherits ViewModelBase
Public Sub New()
Source = EmployeesDataModel.GetEmployees()
States = Source.[Select](Function(x) x.StateProvinceName).Distinct().ToList()
Columns = New ObservableCollection(Of Column)() From {New Column(SettingsType.Default, NameOf(Employee.FirstName)), New Column(SettingsType.Default, NameOf(Employee.LastName)), New LookupColumn(SettingsType.Lookup, NameOf(Employee.StateProvinceName), States), New BindingColumn(SettingsType.Binding, "Cities[0]", "City1"), New BindingColumn(SettingsType.Binding, "Cities[1]", "City2")}
End Sub
Public ReadOnly Property Source As IList(Of Employee)
Public ReadOnly Property States As List(Of String)
Public ReadOnly Property Columns As ObservableCollection(Of Column)
End Class
Public Class Column
Inherits BindableBase
Public Sub New(ByVal settings As SettingsType, ByVal fieldname As String)
Me.Settings = settings
Me.FieldName = fieldname
End Sub
Public ReadOnly Property Settings As SettingsType
Public ReadOnly Property FieldName As String
End Class
Public Class LookupColumn
Inherits Column
Public Sub New(ByVal settings As SettingsType, ByVal fieldname As String, ByVal source As IList)
MyBase.New(settings, fieldname)
Me.Source = source
End Sub
Public ReadOnly Property Source As IList
End Class
Public Class BindingColumn
Inherits Column
Public Sub New(ByVal settings As SettingsType, ByVal fieldname As String, ByVal header As String)
MyBase.New(settings, fieldname)
Me.Header = header
End Sub
Public ReadOnly Property Header As String
End Class
End Namespace