/
Window1.xaml.cs
76 lines (73 loc) · 2.46 KB
/
Window1.xaml.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Documents;
using DevExpress.Data;
using DevExpress.Xpf.Grid;
namespace DXGrid_DisplayGroupSummaries {
public partial class Window1 : Window {
public Window1() {
InitializeComponent();
grid.ItemsSource = new AccountList().GetData();
grid.GroupBy(grid.Columns["Married"], ColumnSortOrder.Ascending);
}
private void CreateGroupSummaries() {
grid.GroupSummary.Add(new GridSummaryItem() {
FieldName = "Age",
SummaryType = SummaryItemType.Min
});
grid.GroupSummary.Add(new GridSummaryItem() {
FieldName = "Age",
SummaryType = SummaryItemType.Max
});
}
private void grid_CustomSummaryExists(object sender, CustomSummaryExistEventArgs e) {
e.Exists = e.GroupLevel == 0;
}
}
public class AccountList {
public List<Account> GetData() {
return CreateAccounts();
}
private List<Account> CreateAccounts() {
List<Account> list = new List<Account>();
list.Add(new Account() {
UserName = "Nick White",
RegistrationDate = DateTime.Today,
Married = true,
Age = 42
});
list.Add(new Account() {
UserName = "Jack Rodman",
RegistrationDate = new DateTime(2009, 5, 10),
Married = false,
Age = 30
});
list.Add(new Account() {
UserName = "Sandra Sherry",
RegistrationDate = new DateTime(2008, 12, 22),
Married = false,
Age = 18
});
list.Add(new Account() {
UserName = "Sabrina Vilk",
RegistrationDate = DateTime.Today,
Married = true,
Age = 24
});
list.Add(new Account() {
UserName = "Mike Pearson",
RegistrationDate = new DateTime(2008, 10, 18),
Married = true,
Age = 37
});
return list;
}
}
public class Account {
public string UserName { get; set; }
public DateTime RegistrationDate { get; set; }
public bool Married { get; set; }
public int Age { get; set; }
}
}