markus / ConvertService / ServiceBase / Markus.Mvvm.ToolKit / ViewModelBase.cs @ d48260a2
이력 | 보기 | 이력해설 | 다운로드 (1.86 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 | 6f6e7dbf | taeseongkim | public bool IsDesignMode |
10 | { |
||
11 | get |
||
12 | { |
||
13 | return DesignerProperties.GetIsInDesignMode(new DependencyObject()); |
||
14 | } |
||
15 | private set { } |
||
16 | } |
||
17 | 53c9637d | taeseongkim | |
18 | 0498c12e | taeseongkim | #region ViewModel Base Binding |
19 | |||
20 | 53c9637d | taeseongkim | ViewModelBase viewModel; |
21 | |||
22 | public ViewModelBase ViewModel |
||
23 | { |
||
24 | get { return viewModel; } |
||
25 | set { viewModel = value; } |
||
26 | } |
||
27 | |||
28 | public string Name |
||
29 | { |
||
30 | 0498c12e | taeseongkim | get { return ViewModel?.Name; } |
31 | 53c9637d | taeseongkim | set |
32 | { |
||
33 | 0498c12e | taeseongkim | if (ViewModel?.Name != value) |
34 | 53c9637d | taeseongkim | { |
35 | ViewModel.Name = value; |
||
36 | OnPropertyChanged(()=>Name); |
||
37 | } |
||
38 | } |
||
39 | } |
||
40 | 0498c12e | taeseongkim | |
41 | private bool isAcitve; |
||
42 | |||
43 | public bool IsAcitve |
||
44 | { |
||
45 | get { return isAcitve; } |
||
46 | set |
||
47 | { |
||
48 | if (isAcitve != value) |
||
49 | { |
||
50 | isAcitve = value; |
||
51 | OnPropertyChanged(() => isAcitve); |
||
52 | } |
||
53 | } |
||
54 | } |
||
55 | |||
56 | #endregion |
||
57 | |||
58 | #region Command |
||
59 | |||
60 | private ICommand _ClosingCommand; |
||
61 | public ICommand ClosingCommand |
||
62 | { |
||
63 | get => _ClosingCommand ?? (_ClosingCommand = new RelayCommand(param => this.Closed())); |
||
64 | } |
||
65 | |||
66 | private ICommand _LoadedCommand; |
||
67 | public ICommand LoadedCommand |
||
68 | { |
||
69 | get => _LoadedCommand ?? (_LoadedCommand = new RelayCommand(param => this.Loaded())); |
||
70 | } |
||
71 | |||
72 | #endregion Command |
||
73 | |||
74 | public virtual void Closed() |
||
75 | { |
||
76 | isAcitve = false; |
||
77 | } |
||
78 | |||
79 | public virtual void Loaded() |
||
80 | { |
||
81 | isAcitve = true; |
||
82 | } |
||
83 | 53c9637d | taeseongkim | } |
84 | } |