Back to Devexpress

DocumentPreviewWindow.PreviewControl Property

wpf-devexpress-dot-xpf-dot-printing-dot-documentpreviewwindow.md

latest3.2 KB
Original Source

DocumentPreviewWindow.PreviewControl Property

Provides access to the integrated document preview control.

Namespace : DevExpress.Xpf.Printing

Assembly : DevExpress.Xpf.Printing.v25.2.dll

NuGet Package : DevExpress.Wpf.Printing

Declaration

csharp
public DocumentPreviewControl PreviewControl { get; }
vb
Public ReadOnly Property PreviewControl As DocumentPreviewControl

Property Value

TypeDescription
DocumentPreviewControl

A DocumentPreviewControl object that is integrated in the current window.

|

Remarks

To create a custom DocumentPreviewWindow, assign the corresponding XtraReport or link to the DocumentViewerControl.DocumentSource property (available via the PreviewControl property).

csharp
using DevExpress.Xpf.Printing;
using System.Windows;
// ...

private void Button_Click(object sender, RoutedEventArgs e) {
    XtraReport1 report = new XtraReport1();
    var window = new DocumentPreviewWindow();
    window.PreviewControl.DocumentSource = report;
    report.CreateDocument();
    window.Show();
}
vb
Imports DevExpress.Xpf.Printing
Imports System.Windows
' ...

Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
    Dim report As New XtraReport1()
    Dim window = New DocumentPreviewWindow()
    window.PreviewControl.DocumentSource = report
    report.CreateDocument()
    window.Show()
End Sub

Call the XtraReport.CreateDocument method before you display the Print Preview. As an alternative, enable the PreviewControl.RequestDocumentCreation property before you specify the DocumentSource - so that Print Preview creates a document. Print Preview generates documents asynchronously in a separate task to allow other tasks to run concurrently. If you need Print Preview to create documents synchronously, disable the PreviewControl.UseAsyncDocumentCreation property.

See Also

DocumentSource

DocumentPreviewWindow

DocumentPreviewWindow Members

DevExpress.Xpf.Printing Namespace