markus / ConvertService / ServiceController / Markus.Mvvm.ToolKit / ViewModelBase.cs @ 5c387707
이력 | 보기 | 이력해설 | 다운로드 (1.66 KB)
1 |
using System.ComponentModel; |
---|---|
2 |
using System.Windows; |
3 |
using System.Windows.Input; |
4 |
|
5 |
namespace Markus.Mvvm.ToolKit |
6 |
{ |
7 |
public abstract class ViewModelBase : NotifyExpectation |
8 |
{ |
9 |
#region ViewModel Base Binding |
10 |
|
11 |
ViewModelBase viewModel; |
12 |
|
13 |
public ViewModelBase ViewModel |
14 |
{ |
15 |
get { return viewModel; } |
16 |
set { viewModel = value; } |
17 |
} |
18 |
|
19 |
public string Name |
20 |
{ |
21 |
get { return ViewModel?.Name; } |
22 |
set |
23 |
{ |
24 |
if (ViewModel?.Name != value) |
25 |
{ |
26 |
ViewModel.Name = value; |
27 |
OnPropertyChanged(()=>Name); |
28 |
} |
29 |
} |
30 |
} |
31 |
|
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 |
} |
75 |
} |