-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommandBinding.cls
44 lines (37 loc) · 1.2 KB
/
CommandBinding.cls
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
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "CommandBinding"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'@Folder MVVM.Infrastructure.Binding
Option Explicit
Private WithEvents UI As msForms.CommandButton
Attribute UI.VB_VarHelpID = -1
Private Type TBinding
ViewModel As Object
Command As ICommand
' Context As Object
CanExecuteContext As Object
ExecuteContext As Object
End Type
Private this As TBinding
Public Sub Initialize(ByVal ViewModel As Object, ByVal Control As msForms.CommandButton, ByVal Command As ICommand, _
Optional ByVal CanExecuteContext As Object, Optional ByVal ExecuteContext As Object)
Set UI = Control
Set this.Command = Command
' Set this.Context = Context
Set this.CanExecuteContext = CanExecuteContext
Set this.ExecuteContext = ExecuteContext
End Sub
'Private Sub RegisterPropertyChanged(ByVal Source As INotifyPropertyChanged)
' Source.RegisterHandler Me
'End Sub
Private Sub UI_Click()
If this.Command.CanExecute(this.CanExecuteContext) Then
this.Command.Execute this.ExecuteContext
End If
End Sub