-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathFriendViewModel.cs
45 lines (40 loc) · 1.35 KB
/
FriendViewModel.cs
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
using System.Collections.ObjectModel;
using interfacebased.DataModel;
using observingobjects;
namespace interfacebased.FriendDetail
{
public class FriendViewModel : BaseViewModel, IFriendViewModel
{
private Friend m_friend;
private IHandleFriendChanged m_friendChangedHandler;
public FriendViewModel(Friend friend, IHandleFriendChanged friendChangedHandler)
{
m_friend = friend;
m_friendChangedHandler = friendChangedHandler;
AvailableColors = new ObservableCollection<HairColor>()
{
new HairColor("Black"),
new HairColor("White"),
new HairColor("Red"),
new HairColor("Brown"),
new HairColor("Green"),
new HairColor("Pink"),
new HairColor("Blue"),
new HairColor("Yellow"),
};
}
public string FirstName => m_friend.FirstName;
public ObservableCollection<HairColor> AvailableColors { get; }
public string LastName => m_friend.LastName;
public HairColor HairColor
{
get => m_friend.HairColor;
set
{
m_friend.HairColor = value;
OnPropertyChanged();
m_friendChangedHandler.OnFriendChanged();
}
}
}
}