-
-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathLockingDialogViewModel.cs
More file actions
61 lines (49 loc) · 1.59 KB
/
LockingDialogViewModel.cs
File metadata and controls
61 lines (49 loc) · 1.59 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
using System;
using Prism.Commands;
using Prism.Dialogs;
namespace PrismSample.ViewModels
{
public class LockingDialogViewModel : BaseViewModel, IDialogAware
{
public LockingDialogViewModel()
{
CloseCommand = new DelegateCommand(OnCloseTapped);
}
private string _question;
public string Question
{
get => _question;
set => SetProperty(ref _question, value);
}
private bool _canClose;
public bool CanClose
{
get => _canClose;
set => SetProperty(ref _canClose, value);
}
private bool _closeOnTap;
public bool CloseOnTap
{
get => _closeOnTap;
set => SetProperty(ref _closeOnTap, value);
}
private void OnCloseTapped()
{
RequestClose(new DialogParameters());
}
public DelegateCommand CloseCommand { get; }
public event Action<IDialogParameters> RequestClose;
public bool CanCloseDialog() => CanClose;
public void OnDialogClosed() { }
public void OnDialogOpened(IDialogParameters parameters)
{
// When not using IAutoInitialize, get values from parameters
// For sample 2 & 3
if (parameters.ContainsKey("Question"))
Question = parameters.GetValue<string>("Question");
// For sample 3
if (parameters.ContainsKey("CloseOnTap"))
CloseOnTap = CanClose = parameters.GetValue<bool>("CloseOnTap");
}
}
}