-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainViewModel.cs
More file actions
30 lines (28 loc) · 1.01 KB
/
MainViewModel.cs
File metadata and controls
30 lines (28 loc) · 1.01 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
using System;
using DevExpress.Mvvm;
using DevExpress.Mvvm.DataAnnotations;
namespace CompositeCommandBehaviorExample.ViewModel {
public class MainViewModel : ViewModelBase {
public virtual string Text { get; set; }
public virtual string SavedText { get; set; }
bool IsSaved { get { return SavedText == Text; } }
protected IMessageBoxService MessageService { get { return GetService<IMessageBoxService>(); } }
[Command]
public void Save() {
SavedText = Text;
}
public bool CanSave() {
return !IsSaved;
}
[Command]
public void Close() {
if(!IsSaved && MessageService.ShowMessage("Do you want to close the document and lost unsaved changes?", "Warning", MessageButton.YesNo) == MessageResult.No)
return;
Text = String.Empty;
SavedText = String.Empty;
}
public bool CanClose() {
return !String.IsNullOrEmpty(Text);
}
}
}