DocumentViewer Class
A control that allows you to preview, print, save, and export a GridControl‘s data or reports created with the DevExpress Reports Suite.
Namespace: DevExpress.WinUI.DocumentViewer
Assembly: DevExpress.WinUI.DocumentViewer.v21.2.dll
Declaration
Remarks
Supported Objects
You can use the DocumentViewer to preview, print, save, and export the following files and objects:
- Objects implementing the IReport interface
A report layout.
A Reporting, DXperience, or Universal subscription is required to display an object that implements the IReport interface in the DocumentViewer. For pricing information, refer to the DevExpress Products matrix.
Refer to the following topic for more information on how to create a report layout: Create a Report in Visual Studio
- Objects that implement the ILink interface
You can use the DocumentViewer to preview, print, and export GridControl‘s data.
Refer to the following topic for more information on how to print a GridControl Print and Export Data
- Report Documents (.PRNX file)
A report document that is built from a report layout.
Refer to the following topic for more information on the .PRNX files: Store Report Documents
In the DocumentViewer, all the available objects and files described above are called a document.
Display Documents
Use the DocumentSource property to display a document in the DocumentViewer.
Save Documents
Call the Save(String) method to save the opened document to a .PRNX file at the specified location.
You can also use the ShowSaveDialogCommand or click the Save As button in the toolbar to open the Save As dialog.
Export Documents
Call the Export(ExportFormats, String) method to export the opened document. Pass a file format as the first parameter and the file path as second parameter.
You can also use the ShowExportDialogCommand or click the Export button in the toolbar to open the Export dialog.
You can export the opened document to the following formats:
Print Documents
Call the ShowPrintDialogCommand or click the Print button in the toolbar to open the Print dialog.
Specify and View IReport Parameters
Set the ShowParameters property to true
to display the Parameters panel.
You can also use the ToggleReportParameterPanelCommand or click the Parameters button in the toolbar to open the Parameters panel.
The DevExpress Report Suite’s API allows you to specify a .REPX parameter value. Refer to the following topic for more information on report parameters: Specify Parameter Values.
Create a Custom Toolbar
To create a DocumentViewer‘s custom command bar items, set the ShowCommandBar property to false
and define a CommandBar in XAML prior to the DocumentViewer instance.
The following code creates a custom toolbar with the standard DocumentViewer‘s commands and adds the Back and Close AppBarButtons and a link to this documentation page (a HyperlinkButton inside the AppBarElementContainer ):
<Page ...
xmlns:dxdv="using:DevExpress.WinUI.DocumentViewer">
<Grid RowDefinitions="Auto,*">
<CommandBar HorizontalAlignment="Left" IsOpen="False" DefaultLabelPosition="Right">
<AppBarButton Click="AppBarButton_Click">
<FontIcon Glyph="" />
</AppBarButton>
<AppBarSeparator/>
<AppBarButton Label="Open..." Command="{x:Bind documentViewer.Commands.ShowOpenDialogCommand}">
<FontIcon Glyph="" />
</AppBarButton>
<AppBarButton Label="Save As..." Command="{x:Bind documentViewer.Commands.ShowSaveDialogCommand}">
<FontIcon Glyph=""/>
</AppBarButton>
<AppBarButton Label="Print..." Command="{x:Bind documentViewer.Commands.ShowPrintDialogCommand}">
<FontIcon Glyph="" />
</AppBarButton>
<AppBarElementContainer VerticalContentAlignment="Center">
<StackPanel Orientation="Horizontal" Spacing="5" Margin="8,0">
<TextBlock Text="Zoom" FontSize="12" VerticalAlignment="Center" Margin="5,11,4,12"/>
<ComboBox Padding="10,-2,0,0" IsEnabled="False" SelectedIndex="2" Width="78" FontSize="12"
VerticalAlignment="Center" VerticalContentAlignment="Center">
<ComboBox.Items>
<ComboBoxItem Content="50%" Tag="50"/>
<ComboBoxItem Content="75%" Tag="75"/>
<ComboBoxItem Content="100%" Tag="100"/>
<ComboBoxItem Content="125%" Tag="125"/>
<ComboBoxItem Content="150%" Tag="150"/>
<ComboBoxItem Content="175%" Tag="175"/>
<ComboBoxItem Content="200%" Tag="200"/>
<ComboBoxItem Content="225%" Tag="225"/>
<ComboBoxItem Content="250%" Tag="250"/>
</ComboBox.Items>
</ComboBox>
</StackPanel>
</AppBarElementContainer>
<AppBarButton Label="Export..." Command="{x:Bind documentViewer.Commands.ShowExportDialogCommand}">
<FontIcon Glyph="" />
</AppBarButton>
<AppBarToggleButton Label="Parameters" Command="{x:Bind documentViewer.Commands.ToggleReportParameterPanelCommand}">
<FontIcon Glyph="" />
</AppBarToggleButton>
<AppBarButton Icon="Cancel" Label="Close" Command="{x:Bind documentViewer.Commands.CloseDocumentCommand}">
<FontIcon Glyph="" />
</AppBarButton>
<AppBarSeparator/>
<AppBarElementContainer Height="30">
<HyperlinkButton NavigateUri="https://docs.devexpress.com/WinUI/DevExpress.WinUI.DocumentViewer.DocumentViewer" Content="Documentation"/>
</AppBarElementContainer>
</CommandBar>
<dxdv:DocumentViewer x:Name="documentViewer" ShowCommandBar="False" Grid.Row="1"/>
</Grid>
</Page>
Visual Elements
The DocumentViewer contains of the following UI elements:
API
The DocumentViewer includes the following properties, methods, events, and commands:
Member | Description |
---|---|
Gets or sets the DocumentViewer‘s document source. This is a dependency property. | |
Saves the opened document to the specified file. | |
Exports the document with the specified name, path, and file format. | |
Provides access to DocumentViewer commands. | |
Gets or sets the index of the current page. This is a dependency property. | |
Gets the total number of pages in the opened document. | |
Gets or sets whether to show a DocumentViewer‘s command bar. This is a dependency property. | |
Gets or sets the opened document’s zoom factor. This is a dependency property. | |
Occurs after the DocumentViewer loads a document. |
Commands
Each of the DocumentViewer‘s Commands (except the CloseDocumentCommand) is bound to a UI element.
Document Navigation Commands
Command | Description | Bound UI Element |
---|---|---|
Gets or sets the command that navigates to the first page of the document. | ||
Gets or sets the command that navigates to a specific page of the document. | ||
Gets or sets the command that navigates to the last page of the document. | ||
Gets or sets the command that navigates to the next page. | ||
Gets or sets the command that navigates to the previous page. |
Dialog Commands
Command | Description | Bound UI Element |
---|---|---|
Gets or sets the command that opens the Export dialog. | ||
Gets or sets the command that opens the Open File dialog. | ||
Gets or sets the command that opens the Print File dialog. | ||
Gets or sets the command that opens the Save File dialog. |
Miscellaneous Commands
Command | Description | Bound UI Element |
---|---|---|
Gets or sets the command that closes the document in the DocumentViewer. | − | |
Gets or sets the command that toggles the visibility of the Report Parameter Panel that displays the current .REPX document’s parameters. | ||
Gets or sets the command that changes the zoom factor. |