Skip to main content
A newer version of this page is available. .
All docs
V21.2

Invoke a Document Viewer

  • 2 minutes to read

Note

An active DevExpress Reporting Subscription is required to use the API described in this tutorial.

This topic describes how to use the Document Viewer control in WinUI applications.

To get started with this tutorial, open an existing WinUI application or create a new application.

Display an Empty Document Viewer

You can display a Document Viewer and open a report document later. Do the following to display an empty Document Viewer:

  1. Install the DevExpress.WinUI NuGet package. Right-click the solution in Solution Explorer and select Manage NuGet Packages. In the invoked NuGet Package Manager, set Package source to DevExpress, locate the DevExpress.WinUI package, and click Install.

  2. Define the Document Viewer in XAML to display a Document Viewer control without a document.

    <Window
        xmlns:dxdvr="using:DevExpress.WinUI.DocumentViewer">
        <dxdvr:DocumentViewer/>
    </Window>
    

Display a Report

Specify the DocumentSource property to load the report to a DocumentViewer.

The following code illustrates how to specify the DocumentSource property in the DocumentViewer‘s Loaded event handler:

<Window
    xmlns:dxdvr="using:DevExpress.WinUI.DocumentViewer">
    ...
    <dxdvr:DocumentViewer Loaded="DocumentViewer_Loaded"/>
</Window>
private void DocumentViewer_Loaded(object sender, RoutedEventArgs e) {
    TestReport report = new TestReport();
    report.CreateDocument();
    documentViewer.DocumentSource = report;
}