This example shows how to use simple templates in DevExpress printing mechanism. The most important thing you can't miss is that it is absolutely essential to use DevExpress template controls in DataTemplate - plain Silverlight controls are simply removed when the template is processed. In this example this is <dxe:TextEdit /> used instead of Silverlight's <TextBlock>.
<UserControl
[....]
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors">
<UserControl.Resources>
<DataTemplate x:Key="headerTemplate">
<dxe:TextEdit Text="{Binding Path=Content, Mode=OneWay}" />
</DataTemplate>
</UserControl.Resources>
[....]
</UserControl>
var preview = new DocumentPreviewWindow();
var link = CreateExportServiceLink(gridControl, preview);
PrepareHeader(link);
private PrintableControlLink CreateExportServiceLink(
IPrintableControl gridControl,
DocumentPreviewWindow documentPreviewWindow)
{ var link = new PrintableControlLink(gridControl)
{
ExportServiceUri = "http://127.0.0.1:8080/IExportService",
Landscape = true
};
var model = new LinkPreviewModel(link);
documentPreviewWindow.Model = model;
return link;}
private void PrepareHeader(PrintableControlLink link){
link.ReportHeaderTemplate = (DataTemplate)Resources["headerTemplate"];
link.ReportHeaderData = "Text to be displayed";
}
No comments:
Post a Comment
If you like this post, please leave a comment :)