-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainViewModel.vb
62 lines (49 loc) · 2.15 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
Imports DevExpress.Mvvm
Imports DevExpress.Mvvm.Xpf
Imports System
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
Namespace CustomFiltering_MVVM
Public Class MainViewModel
Inherits ViewModelBase
Public Property HideEvenItems As Boolean
Get
Return GetValue(Of Boolean)(NameOf(MainViewModel.HideEvenItems))
End Get
Set(ByVal value As Boolean)
SetValue(value, New Action(AddressOf UpdateFiltrationLogic), NameOf(MainViewModel.HideEvenItems))
End Set
End Property
Public Property HideOddItems As Boolean
Get
Return GetValue(Of Boolean)(NameOf(MainViewModel.HideOddItems))
End Get
Set(ByVal value As Boolean)
SetValue(value, New Action(AddressOf UpdateFiltrationLogic), NameOf(MainViewModel.HideOddItems))
End Set
End Property
Public Property CustomRowFilterCommand As ICommand(Of RowFilterArgs)
Get
Return GetValue(Of ICommand(Of RowFilterArgs))(NameOf(MainViewModel.CustomRowFilterCommand))
End Get
Set(ByVal value As ICommand(Of RowFilterArgs))
SetValue(value, NameOf(MainViewModel.CustomRowFilterCommand))
End Set
End Property
Public ReadOnly Property Items As ObservableCollection(Of Object)
Public Sub New()
Items = New ObservableCollection(Of Object)(GetItems())
UpdateFiltrationLogic()
End Sub
Private Shared Function GetItems() As IEnumerable(Of Object)
Return New Object() {"A", "B", "C", "D", "E", "F", "G", "H"}
End Function
Private Sub UpdateFiltrationLogic()
CustomRowFilterCommand = New DelegateCommand(Of RowFilterArgs)(AddressOf CustomRowFilter)
End Sub
Private Sub CustomRowFilter(ByVal args As RowFilterArgs)
If HideOddItems AndAlso args.SourceIndex Mod 2 = 1 Then args.Visible = False
If HideEvenItems AndAlso args.SourceIndex Mod 2 = 0 Then args.Visible = False
End Sub
End Class
End Namespace