-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBase.cs
More file actions
82 lines (63 loc) · 2.08 KB
/
Base.cs
File metadata and controls
82 lines (63 loc) · 2.08 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Copyright (c) 2015 WildCardJoker
// Licensed under the MIT License: http://opensource.org/licenses/MIT
// Created: 2015-07-12
// Last Modified: 2015-07-25-8:22 PM
#region Using Directives
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Input;
using ContactViewModel.Annotations;
using wcj;
#endregion
namespace ContactViewModel
{
public class Base : INotifyPropertyChanged, INotifyCollectionChanged
{
#region Fields
private Person _contactPerson;
private ICommand _newContactCommand;
private ObservableCollection<Person> _persons;
#endregion
#region Properties
public Person ContactPerson
{
get { return _contactPerson; }
set
{
_contactPerson = value;
OnPropertyChanged("ContactPerson");
}
}
public ICommand NewContactCommand => _newContactCommand ??
(_newContactCommand =
new RelayCommand(param => AddNewContact()));
public ObservableCollection<Person> Persons
{
get { return _persons; }
set
{
_persons = value;
OnPropertyChanged("Persons");
}
}
#endregion
#region INotifyCollectionChanged Members
public event NotifyCollectionChangedEventHandler CollectionChanged;
#endregion
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
#endregion
private void AddNewContact()
{
ContactPerson = new Person();
}
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
var handler = PropertyChanged;
handler?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}