Mercurial > silverbladetech
comparison delete me/SilverlightValidation/ViewModels/UserListViewModel.cs @ 59:3591c26bd63e
MVVMLight added
author | Steven Hollidge <stevenhollidge@hotmail.com> |
---|---|
date | Sat, 21 Apr 2012 19:20:28 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
58:241e2f22ed3c | 59:3591c26bd63e |
---|---|
1 using System.Collections.Generic; | |
2 using System.Collections.ObjectModel; | |
3 using System.Windows.Input; | |
4 using SilverlightValidation.Commands; | |
5 using SilverlightValidation.Models; | |
6 using SilverlightValidation.Validators; | |
7 | |
8 namespace SilverlightValidation.ViewModels | |
9 { | |
10 public class UserListViewModel | |
11 { | |
12 public UserListViewModel(IList<UserModel> models, UserModelValidator validator) | |
13 { | |
14 Data = new ObservableCollection<UserViewModel>(); | |
15 | |
16 foreach (var model in models) | |
17 Data.Add(new UserViewModel(model, validator)); | |
18 | |
19 AddCommand = new RelayCommand(AddCommandExecute); | |
20 DeleteCommand = new RelayCommand(DeleteCommandExecute); | |
21 } | |
22 | |
23 #region Properties | |
24 | |
25 public ObservableCollection<UserViewModel> Data { get; set; } | |
26 | |
27 public UserViewModel SelectedItem { get; set; } | |
28 | |
29 #endregion | |
30 | |
31 #region Commands | |
32 | |
33 public ICommand AddCommand { get; set; } | |
34 public ICommand DeleteCommand { get; set; } | |
35 | |
36 private void AddCommandExecute(object obj) | |
37 { | |
38 | |
39 } | |
40 | |
41 private void DeleteCommandExecute(object obj) | |
42 { | |
43 Data.Remove(SelectedItem); | |
44 } | |
45 | |
46 #endregion | |
47 } | |
48 } |