-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChildViewModel.cs
39 lines (38 loc) · 1.56 KB
/
ChildViewModel.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
36
37
38
39
using System;
using System.Windows;
using System.Windows.Input;
using System.Windows.Threading;
using DevExpress.Mvvm;
namespace DXSample.ViewModels {
public class ChildViewModel : ViewModelBase {
protected ICurrentWindowService CurrentWindowService { get { return this.GetService<ICurrentWindowService>(); } }
public ICommand CloseWindowCommand { get; private set; }
public ICommand TemporarilyHideWindowCommand { get; private set; }
public string Caption {
get { return GetProperty(() => Caption); }
set { SetProperty(() => Caption, value); }
}
public WindowState WindowState {
get { return GetProperty(() => WindowState); }
set { SetProperty(() => WindowState, value); }
}
public ChildViewModel() {
CloseWindowCommand = new DelegateCommand(CloseWindow);
TemporarilyHideWindowCommand = new DelegateCommand(TemporarilyHideWindow);
}
void CloseWindow() {
this.CurrentWindowService.Close();
}
void TemporarilyHideWindow() {
this.CurrentWindowService.Hide();
var timer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(3) };
timer.Tick += (o, e) => {
this.CurrentWindowService.SetWindowState(WindowState.Maximized);
this.CurrentWindowService.Show();
this.CurrentWindowService.Activate();
timer.Stop();
};
timer.Start();
}
}
}