Back to Devexpress

Override Document Preview Commands

xtrareports-115362-desktop-reporting-wpf-reporting-wpf-reporting-document-preview-api-and-customization-override-document-preview-commands.md

latest1.5 KB
Original Source

Override Document Preview Commands

  • Oct 09, 2023
  • 2 minutes to read

This example demonstrates how to override commands available on the WPF Document Preview toolbar. In particular, it shows how to disable the Export to PDF command.

To start with this example, create a new WPF application or open an existing one, and prepare a simple report to display in the Document Preview.

To override a command in the WPF Document Preview, do the following.

  1. Create a custom Document Preview object by inheriting from the DocumentPreviewControl class.

  2. Override methods that define logic behind the required command. For instance, to customize the Export command, override the Export and CanExport methods as shown in the sample below.

  3. To display the customized Document Preview, create its instance in code. Specify the required Document Preview settings. To display a report, assign it to the DocumentSource property of the custom DocumentPreviewControl.

  4. Run the application to see the result.

Tip

Online Examples :