-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainViewModel.cs
27 lines (26 loc) · 1.06 KB
/
MainViewModel.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
using DevExpress.Mvvm;
using DevExpress.Mvvm.DataAnnotations;
using DevExpress.Mvvm.POCO;
using System.Collections.ObjectModel;
namespace Example.ViewModel {
[POCOViewModel]
public class MainViewModel {
public virtual ObservableCollection<Person> Persons { get; protected set; }
protected virtual IMessageBoxService MessageBoxService { get { return null; } }
public void Initialize() {
Persons = new ObservableCollection<Person>();
Persons.Add(ViewModelSource.Create(() => new Person() { FirstName = "John", LastName = "Smith" }));
Persons.Add(ViewModelSource.Create(() => new Person() { FirstName = "Alex", LastName = "Carter" }));
}
public void Edit(Person person) {
MessageBoxService.Show(string.Format("{0} {1}", person.FirstName, person.LastName));
}
public bool CanEdit(Person person) {
return person != null;
}
}
public class Person {
public string FirstName { get; set; }
public string LastName { get; set; }
}
}