/
MainViewModel.cs
61 lines (49 loc) · 2.37 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
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
using DevExpress.Xpf.Mvvm;
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
namespace FilterCombo {
class MainViewModel : ViewModelBase {
ObservableCollection<Car> _cars;
ObservableCollection<ComboItem> _comboItems;
public MainViewModel() {
Cars = new ObservableCollection<Car>();
Cars.Add(new Car() { Color = "Red", FilterType = RowFilterType.Type1 });
Cars.Add(new Car() { Color = "Azure", FilterType = RowFilterType.Type2 });
Cars.Add(new Car() { Color = "Blue", FilterType = RowFilterType.Type1 });
ComboItems = new ObservableCollection<ComboItem>();
ComboItems.Add(new ComboItem() { Color = "Red", FilterType = RowFilterType.Type1 });
ComboItems.Add(new ComboItem() { Color = "Brown", FilterType = RowFilterType.Type1 });
ComboItems.Add(new ComboItem() { Color = "Blue", FilterType = RowFilterType.Type1 });
ComboItems.Add(new ComboItem() { Color = "Violet", FilterType = RowFilterType.Type2 });
ComboItems.Add(new ComboItem() { Color = "Azure", FilterType = RowFilterType.Type2 });
}
public ObservableCollection<Car> Cars { get => _cars; set => SetProperty(ref _cars, value, () => Cars); }
public ObservableCollection<ComboItem> ComboItems { get => _comboItems; set => SetProperty(ref _comboItems, value, () => ComboItems); }
}
public enum RowFilterType {
Type1, Type2
}
public class ComboItem : BindableBase {
private string _color;
private RowFilterType _filterType;
public string Color {
get => _color; set => SetProperty(ref _color, value, () => Color);
}
public RowFilterType FilterType {
get => _filterType; set => SetProperty(ref _filterType, value, () => _filterType);
}
}
public class Car : BindableBase {
private string _color;
private RowFilterType _filterType;
public string Color {
get => _color; set => SetProperty(ref _color, value, () => Color);
}
[RefreshProperties(RefreshProperties.All)]
public RowFilterType FilterType {
get => _filterType; set => SetProperty(ref _filterType, value, () => FilterType);
}
}
}