-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainViewModel.cs
35 lines (33 loc) · 1.5 KB
/
MainViewModel.cs
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
using System.Windows.Input;
using DevExpress.Mvvm;
namespace DXSample.ViewModels {
public class MainViewModel : ViewModelBase {
protected IWindowService WindowService { get { return this.GetService<IWindowService>(); } }
public ICommand ShowChildWindowCommand { get; private set; }
public ICommand CloseChildWindowCommand { get; private set; }
public ICommand RestoreChildWindowCommand { get; private set; }
public ChildViewModel ChildWindowViewModel {
get { return GetValue<ChildViewModel>(); }
set { SetValue(value); }
}
public MainViewModel() {
ShowChildWindowCommand = new DelegateCommand(ShowChildWindow, CanShowChildWindow);
CloseChildWindowCommand = new DelegateCommand(CloseChildWindow, CanCloseChildWindow);
}
public void ShowChildWindow() {
if(ChildWindowViewModel == null)
ChildWindowViewModel = new ChildViewModel() { Caption = "Hello, World!" };
WindowService.Show(ChildWindowViewModel);
}
private bool CanShowChildWindow() {
return !WindowService.IsWindowAlive;
}
private void CloseChildWindow() {
ChildWindowViewModel = null;
WindowService.Close();
}
private bool CanCloseChildWindow() {
return WindowService.IsWindowAlive;
}
}
}