-
-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathTermsDialogViewModel.cs
More file actions
69 lines (58 loc) · 1.88 KB
/
TermsDialogViewModel.cs
File metadata and controls
69 lines (58 loc) · 1.88 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using Prism.AppModel;
using Prism.Commands;
using Prism.Dialogs;
namespace PrismSample.ViewModels
{
public class TermsDialogViewModel : BaseViewModel, IDialogAware, IAutoInitialize
{
public TermsDialogViewModel()
{
Title = "Terms and Conditions";
SubmitCommand = new DelegateCommand(OnSubmitTapped)
.ObservesCanExecute(() => CanContinue);
CancelCommand = new DelegateCommand(OnCancelTapped);
}
public DelegateCommand SubmitCommand { get; }
public DelegateCommand CancelCommand { get; }
private void OnSubmitTapped()
{
RequestClose(new DialogParameters { { "accepted", true } });
}
private bool _cancelled;
private void OnCancelTapped()
{
_cancelled = true;
RequestClose(new DialogParameters { { "accepted", false } });
}
private string _name;
public string Name
{
get => _name;
set { SetProperty(ref _name, value); }
}
private bool _canContinue;
public bool CanContinue
{
get { return _canContinue; }
set { SetProperty(ref _canContinue, value); }
}
private string _emailAddress;
public string EmailAddress
{
get { return _emailAddress; }
set { SetProperty(ref _emailAddress, value); }
}
public event Action<IDialogParameters> RequestClose;
public bool CanCloseDialog() => _cancelled || CanContinue;
public void OnDialogClosed()
{
Console.WriteLine("*** Dialog closed");
}
public void OnDialogOpened(IDialogParameters parameters)
{
if (parameters.ContainsKey("email"))
EmailAddress = parameters.GetValue<string>("email");
}
}
}