Quick Guide to Print Preview Customization
- 2 minutes to read
This document describes various aspects of Document Preview customization:
Execute and Customize Commands
All Document Preview commands implement the ICommand interface. You can execute a specific command by calling its Execute method with a required parameter.
using DevExpress.Xpf.DocumentViewer;
// ...
private void Button_Click(object sender, RoutedEventArgs e) {
if (documentPreview.SetZoomModeCommand.CanExecute(ZoomMode.FitToWidth))
documentPreview.SetZoomModeCommand.Execute(ZoomMode.FitToWidth);
if (documentPreview.PrintCommand.CanExecute(null))
documentPreview.PrintCommand.Execute(null);
}
Tip
See Toolbar Commands and Dialogs for information on available Document Preview commands.
You can change the default command behavior by creating a custom DocumentPreviewControl descendant and overriding methods that define the logic behind this command. Refer to Override Document Preview Commands for an example.
The DocumentCommandProvider class the DocumentViewerControl.CommandProvider property returns stores commands similar to those available at the control level and allows you to customize items (for instance, remove standard commands or add custom ones). See the Customize the Document Preview Toolbar topic for a code sample.
Customize Dialogs and Message Boxes
You can customize the Document Preview default dialogs and message boxes using the corresponding templates:
- DocumentPreviewControl.DialogServiceTemplate
- DocumentPreviewControl.MessageBoxServiceTemplate
- DocumentPreviewControl.SaveFileDialogTemplate
- DocumentViewerControl.OpenFileDialogTemplate
Access the Current Document and Parameters
Use the DocumentPreviewControl.Document property to access the document loaded in the Document Preview.
The DocumentPreviewControl.ParametersModel property provides access to the report parameter settings.
Change Panels’ Visibility
The properties below enable you to control the Document Preview panels‘s visibility:
Property | Description |
---|---|
Specifies whether to display the Document Map automatically if an opened report has any bookmarks assigned to its elements. | |
Indicates whether to show the Parameters panel automatically if an opened report contains any visible parameters. | |
Allows you to specify the Document Map and Parameters panels’ visibility without taking other settings and commands into account. Use the following properties: | |
Specifies the Thumbnails panel’s visibility. |
Document Preview Mouse Events
You can extend the Document Preview interactive capabilities using the following mouse events:
- DocumentPreviewControl.DocumentPreviewMouseClick
- DocumentPreviewControl.DocumentPreviewMouseDoubleClick
- DocumentPreviewControl.DocumentPreviewMouseMove
For code samples, see the following examples online: