markus / ConvertService / ServiceBase / Markus.Mvvm.ToolKit / ViewModelBase.cs @ 05fd750b
이력 | 보기 | 이력해설 | 다운로드 (1.66 KB)
1 | 6f6e7dbf | taeseongkim | using System.ComponentModel; |
---|---|---|---|
2 | using System.Windows; |
||
3 | using System.Windows.Input; |
||
4 | 0498c12e | taeseongkim | |
5 | namespace Markus.Mvvm.ToolKit |
||
6 | 53c9637d | taeseongkim | { |
7 | 45f9a2ad | taeseongkim | public abstract class ViewModelBase : NotifyExpectation |
8 | 53c9637d | taeseongkim | { |
9 | 0498c12e | taeseongkim | #region ViewModel Base Binding |
10 | |||
11 | 53c9637d | taeseongkim | ViewModelBase viewModel; |
12 | |||
13 | public ViewModelBase ViewModel |
||
14 | { |
||
15 | get { return viewModel; } |
||
16 | set { viewModel = value; } |
||
17 | } |
||
18 | |||
19 | public string Name |
||
20 | { |
||
21 | 0498c12e | taeseongkim | get { return ViewModel?.Name; } |
22 | 53c9637d | taeseongkim | set |
23 | { |
||
24 | 0498c12e | taeseongkim | if (ViewModel?.Name != value) |
25 | 53c9637d | taeseongkim | { |
26 | ViewModel.Name = value; |
||
27 | OnPropertyChanged(()=>Name); |
||
28 | } |
||
29 | } |
||
30 | } |
||
31 | 0498c12e | taeseongkim | |
32 | private bool isAcitve; |
||
33 | |||
34 | public bool IsAcitve |
||
35 | { |
||
36 | get { return isAcitve; } |
||
37 | set |
||
38 | { |
||
39 | if (isAcitve != value) |
||
40 | { |
||
41 | isAcitve = value; |
||
42 | OnPropertyChanged(() => isAcitve); |
||
43 | } |
||
44 | } |
||
45 | } |
||
46 | |||
47 | #endregion |
||
48 | |||
49 | #region Command |
||
50 | |||
51 | private ICommand _ClosingCommand; |
||
52 | public ICommand ClosingCommand |
||
53 | { |
||
54 | get => _ClosingCommand ?? (_ClosingCommand = new RelayCommand(param => this.Closed())); |
||
55 | } |
||
56 | |||
57 | private ICommand _LoadedCommand; |
||
58 | public ICommand LoadedCommand |
||
59 | { |
||
60 | get => _LoadedCommand ?? (_LoadedCommand = new RelayCommand(param => this.Loaded())); |
||
61 | } |
||
62 | |||
63 | #endregion Command |
||
64 | |||
65 | public virtual void Closed() |
||
66 | { |
||
67 | isAcitve = false; |
||
68 | } |
||
69 | |||
70 | public virtual void Loaded() |
||
71 | { |
||
72 | isAcitve = true; |
||
73 | } |
||
74 | 53c9637d | taeseongkim | } |
75 | } |