-
Notifications
You must be signed in to change notification settings - Fork 1
/
MainViewModel.vb
37 lines (31 loc) · 1.44 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
Imports DevExpress.Mvvm
Imports DevExpress.Mvvm.POCO
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Diagnostics
Imports System.Windows
Imports System.Windows.Input
Namespace Example.ViewModel
Public Class MainViewModel
Protected ReadOnly Property DialogService() As IDialogService
Get
Return Me.GetService(Of IDialogService)()
End Get
End Property
Private registrationViewModel As RegistrationViewModel = Nothing
Public Sub ShowRegistrationForm()
If registrationViewModel Is Nothing Then
registrationViewModel = New RegistrationViewModel()
End If
Dim registerCommand As New UICommand() With {.Caption = "Register", .IsCancel = False, .IsDefault = True, .Command = New DelegateCommand(Of CancelEventArgs)(Sub(x) myExecuteMethod(), Function(x) (Not String.IsNullOrEmpty(registrationViewModel.UserName)))}
Dim cancelCommand As New UICommand() With {.Id = MessageBoxResult.Cancel, .Caption = "Cancel", .IsCancel = True, .IsDefault = False}
Dim result As UICommand = DialogService.ShowDialog(dialogCommands:= New List(Of UICommand)() From {registerCommand, cancelCommand}, title:= "Registration Dialog", viewModel:= registrationViewModel)
If result Is registerCommand Then
'...
End If
End Sub
Private Sub myExecuteMethod()
Debug.Print("Registration complete")
End Sub
End Class
End Namespace