Quick Guide to Print Preview Customization
- 2 minutes to read
#Execute and Customize Commands
All Document Preview commands implement the ICommand interface. To execute a command, call 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
Document Preview commands available to the user are listed in the following help topic: Toolbar Commands and Dialogs.
You can change the default command behavior. Create a custom DocumentPreviewControl descendant and override methods that define the logic behind a specific command. Review the following help topic to see an example: Override Document Preview Commands.
To customize the commands in the Document preview toolbar, use the DocumentViewerControl.CommandProvider property, which returns the DocumentCommandProvider object. For a code sample, review the following help topic: Customize the Document Preview Toolbar.
#Customize Dialogs and Message Boxes
Use the following templates to customize the Document Preview default dialogs and message boxes:
- 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.ParameterPanelViewModel property provides access to the report parameter settings.
#Hide Panels
The following properties allow you to show and hide the Document Preview panels:
Property | Description |
---|---|
Specifies whether to display the Document Map automatically if a report contains bookmarks. | |
Indicates whether to show the Parameters panel automatically if a report contains visible parameters. | |
Allows you to set the visibility of the Document map and Parameters panels regardless of other settings and commands. Use the following properties: | |
Shows or hides the Thumbnails panel. |
#Handle Mouse Events
Use the following mouse events to add interactivity to the Document Preview.
- DocumentPreviewControl.DocumentPreviewMouseClick
- DocumentPreviewControl.DocumentPreviewMouseDoubleClick
- DocumentPreviewControl.DocumentPreviewMouseMove
For code samples, review the following examples:
#Edit Content in Print Preview
You can validate data input or disable the data entry. Handle the following events to customize editors used for data entry in the edit fields:
Review the following example: How to Validate the Editing Field Value in the Document Preview.