-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainWindowViewModel.cs
More file actions
50 lines (39 loc) · 1.34 KB
/
Copy pathMainWindowViewModel.cs
File metadata and controls
50 lines (39 loc) · 1.34 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
using System.Windows;
using System.Windows.Input;
namespace DialogHost
{
public class MainWindowViewModel : ViewModelBase
{
private IDialogService _dialogService;
private ICommand _cmdShowDialog;
private ICommand _cmdShowTextDialog;
public IDialogService DialogHost
{
get => _dialogService;
}
public ICommand CmdShowDialog
{
get => _cmdShowDialog;
}
public ICommand CmdShowTextDialog
{
get => _cmdShowTextDialog;
}
public MainWindowViewModel(IDialogService dialogService)
{
_dialogService = dialogService;
_cmdShowDialog = new DelegateCommand(async x =>
{
var dialogViewModel = new DialogViewModel();
var result = await _dialogService.ShowDialog(dialogViewModel);
MessageBox.Show(string.Format("Your choice: {0}",result.ToString()));
});
_cmdShowTextDialog = new DelegateCommand(async x =>
{
var dialogViewModel = new DialogTextViewModel();
var result = await _dialogService.ShowDialog(dialogViewModel);
if (result.Value) { MessageBox.Show(string.Format("You typed: {0}", dialogViewModel.TextInput)); }
});
}
}
}