-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainViewModel.vb
More file actions
45 lines (35 loc) · 1.26 KB
/
MainViewModel.vb
File metadata and controls
45 lines (35 loc) · 1.26 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
Imports DevExpress.Mvvm
Imports DevExpress.Mvvm.DataAnnotations
Namespace CompositeCommandBehaviorExample.ViewModel
Public Class MainViewModel
Inherits ViewModelBase
Public Overridable Property Text As String
Public Overridable Property SavedText As String
Private ReadOnly Property IsSaved As Boolean
Get
Return Equals(SavedText, Text)
End Get
End Property
Protected ReadOnly Property MessageService As IMessageBoxService
Get
Return GetService(Of IMessageBoxService)()
End Get
End Property
<Command>
Public Sub Save()
SavedText = Text
End Sub
Public Function CanSave() As Boolean
Return Not IsSaved
End Function
<Command>
Public Sub Close()
If Not IsSaved AndAlso MessageService.ShowMessage("Do you want to close the document and lost unsaved changes?", "Warning", MessageButton.YesNo) = MessageResult.No Then Return
Text = String.Empty
SavedText = String.Empty
End Sub
Public Function CanClose() As Boolean
Return Not String.IsNullOrEmpty(Text)
End Function
End Class
End Namespace