-
Notifications
You must be signed in to change notification settings - Fork 0
/
Window1.xaml.cs
52 lines (46 loc) · 1.74 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
using System.Windows;
using DevExpress.Xpf.Grid;
using DevExpress.Xpf.Printing;
using DevExpress.Xpf.Core;
namespace GridPrint
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private class Product
{
public string Group { get; set; }
public string Name { get; set; }
public decimal Price { get; set; }
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
var productList = new Product[]
{
new Product { Group = "Group 1", Name = "Product 1", Price = 12.94m },
new Product { Group = "Group 1", Name = "Product 2", Price = 35.42m },
new Product { Group = "Group 2", Name = "Product 3", Price = 22.45m },
new Product { Group = "Group 3", Name = "Product 4", Price = 36.99m },
new Product { Group = "Group 3", Name = "Product 5", Price = 76.54m },
new Product { Group = "Group 4", Name = "Product 6", Price = 98.65m }
};
gridControl1.ItemsSource = productList;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
var link = new PrintableControlLink((TableView)gridControl1.View);
link.PageHeaderTemplate = (DataTemplate)Resources["PageHeader"];
link.PageFooterTemplate = (DataTemplate)Resources["PageFooter"];
DocumentPreviewWindow wnd = new DocumentPreviewWindow();
wnd.PreviewControl.DocumentSource = link;
link.CreateDocument();
wnd.Show();
}
}
}