프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / ConvertService / ServiceBase / Markus.Mvvm.ToolKit / ViewModelBase.cs @ d48260a2

이력 | 보기 | 이력해설 | 다운로드 (1.86 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
        public bool IsDesignMode
10
        {
11
            get
12
            {
13
                return DesignerProperties.GetIsInDesignMode(new DependencyObject());
14
            }
15
            private set { }
16
        }
17

    
18
        #region ViewModel Base Binding
19
        
20
        ViewModelBase viewModel;
21

    
22
        public ViewModelBase ViewModel
23
        {
24
            get { return viewModel; }
25
            set { viewModel = value; }
26
        }
27

    
28
        public string Name
29
        {
30
            get { return ViewModel?.Name; }
31
            set
32
            {
33
                if (ViewModel?.Name != value)
34
                {
35
                    ViewModel.Name = value;
36
                    OnPropertyChanged(()=>Name);
37
                }
38
            }
39
        }
40

    
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
    }
84
}
클립보드 이미지 추가 (최대 크기: 500 MB)