-
Notifications
You must be signed in to change notification settings - Fork 0
/
ViewModel.cs
36 lines (33 loc) · 1.25 KB
/
ViewModel.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
using DevExpress.Mvvm;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
namespace GridMVVMColumns {
public class ViewModel : ViewModelBase {
public ViewModel() {
Source = EmployeesDataModel.GetEmployees();
States = Source.Select(x => x.StateProvinceName).Distinct().ToList();
Columns = new ObservableCollection<TextColumn>() {
new TextColumn(nameof(Employee.FirstName)),
new TextColumn(nameof(Employee.LastName)),
new ComboBoxColumn(nameof(Employee.StateProvinceName), States)
};
}
public ObservableCollection<Employee> Source { get; }
public ObservableCollection<TextColumn> Columns { get; }
public List<string> States { get; }
}
public class TextColumn : BindableBase {
public TextColumn(string fieldname) {
FieldName = fieldname;
}
public string FieldName { get; }
}
public class ComboBoxColumn : TextColumn {
public ComboBoxColumn(string fieldname, IList items) : base(fieldname) {
Items = items;
}
public IList Items { get; }
}
}