SimpleLink.DetailTemplate Property
Specifies the template for the document’s detail area.
Namespace: DevExpress.Xpf.Printing
Assembly: DevExpress.Xpf.Printing.v24.1.dll
NuGet Package: DevExpress.Wpf.Printing
Declaration
Property Value
Type | Description |
---|---|
DataTemplate | A DataTemplate object. |
Remarks
Use the DetailTemplate property to define a data template for a document’s detail area.
You can customize other document areas via the corresponding properties provided by the TemplatedLink class.
- TemplatedLink.TopMarginTemplate and TemplatedLink.BottomMarginTemplate;
- TemplatedLink.ReportHeaderTemplate and TemplatedLink.ReportFooterTemplate;
- TemplatedLink.PageHeaderTemplate and TemplatedLink.PageFooterTemplate.
For more information on document areas, see Printing Links.
Example
This example demonstrates how to use SimpleLink to print data from a non-hierarchical datasource.
To do this, perform the following steps.
- Create a DataTemplate for a single detail row and assign it to the
SimpleLink.DetailTemplate
property; - Set the SimpleLink.DetailCount property to the total count of data rows in a data source;
- Handle the SimpleLink.CreateDetail event, and provide data for its CreateAreaEventArgs.Data parameter;
- Call the LinkBase.CreateDocument method to generate report pages.
using System;
using System.Globalization;
using System.Windows;
using DevExpress.Xpf.Printing;
// ...
string[] data;
private void button1_Click(object sender, RoutedEventArgs e) {
// Create an array of strings.
data = CultureInfo.CurrentCulture.DateTimeFormat.DayNames;
// Create a link and specify a template and detail count for it.
SimpleLink link = new SimpleLink();
link.DetailTemplate = (DataTemplate)Resources["dayNameTemplate"];
link.DetailCount = data.Length;
// Create a document.
link.CreateDetail += new EventHandler<CreateAreaEventArgs>(link_CreateDetail);
// Show a Print Preview window.
PrintHelper.ShowPrintPreviewDialog(this, link);
}
void link_CreateDetail(object sender, CreateAreaEventArgs e) {
e.Data = data[e.DetailIndex];
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the DetailTemplate property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.