-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWindow.xaml.cs
53 lines (45 loc) · 2.39 KB
/
MainWindow.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
using DevExpress.Xpf.Grid;
using System.Windows;
namespace MasterDetailInCode {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
GridControl gridControl = CreateGridControl();
AddDetails(gridControl);
gridControl.Loaded += (d, e) => { (d as GridControl)?.ExpandMasterRow(0); };
grid.Children.Add(gridControl);
}
private GridControl CreateGridControl() {
GridControl gridControl = new GridControl();
gridControl.AutoGenerateColumns = AutoGenerateColumnsMode.AddNew;
gridControl.ItemsSource = Employees.GetEmployees();
gridControl.View = new TableView();
((TableView)gridControl.View).AutoWidth = true;
((TableView)gridControl.View).ShowGroupPanel = false;
gridControl.View.DetailHeaderContent = nameof(Employees);
return gridControl;
}
private void AddDetails(GridControl gridControl) {
GridControl detailGridControl = new GridControl();
detailGridControl.AutoGenerateColumns = AutoGenerateColumnsMode.AddNew;
detailGridControl.View = new TableView();
((TableView)detailGridControl.View).AutoWidth = true;
((TableView)detailGridControl.View).ShowGroupPanel = false;
detailGridControl.View.DetailHeaderContent = nameof(Employee.Orders);
DataControlDetailDescriptor gridDetail = new DataControlDetailDescriptor();
gridDetail.ItemsSourcePath = nameof(Employee.Orders);
gridDetail.DataControl = detailGridControl;
ContentDetailDescriptor customDetail = new ContentDetailDescriptor();
customDetail.ContentTemplate = (DataTemplate)FindResource("notesTemplate");
customDetail.HeaderContent = nameof(Employee.Notes);
ContentDetailDescriptor chartDetail = new ContentDetailDescriptor();
chartDetail.ContentTemplate = (DataTemplate)FindResource("chartTemplate");
chartDetail.HeaderContent = "Stats";
TabViewDetailDescriptor tabDetail = new TabViewDetailDescriptor();
tabDetail.DetailDescriptors.Add(gridDetail);
tabDetail.DetailDescriptors.Add(customDetail);
tabDetail.DetailDescriptors.Add(chartDetail);
gridControl.DetailDescriptor = tabDetail;
}
}
}