How to Use the DocumentPreviewControl in a WPF MVVM Application to Preview a Report
This example demonstrates how to bind the [DocumentPreviewControl.DocumentSource](https://docs.devexpress.com/WPF/DevExpress.Xpf.DocumentViewer.DocumentViewerControl.DocumentSource property to the report source in the ViewModel. The project implements a command to show the report preview in a modal window. In this example the reports are stored in the SQLite database.
The ReportCatalogViewModel view model retrieves reports from a database and defines the following commands:
ShowReport
. Assigns a report instance to the view model property bound to the DocumentViewerControl.DocumentSource property.ShowPreviewInNewWindow
. Creates the DocumentPreviewDialogViewModel view model instance that contains the current report. Uses the DialogService to show the modal window with the report preview.
Files to Look At
- MainWindow.xaml (MainWindow.xaml)
- ReportCatalogViewModel.cs (ReportCatalogViewModel.vb)
- DocumentPreviewDialogViewModel.cs (DocumentPreviewDialogViewModel.vb)
Documentation
- Document Preview API and Customization
- Quick Guide to Print Preview Customization
- DevExpress MVVM Framework