This example demonstrates how to pass data from the ViewModel to a report. The row selected in the Data Grid is used as a report parameter. When the user selects a row and clicks a button, a new modal window is invoked. The window contains the DocumentPreviewControl that displays the report with the specified parameter applied.
The MainViewModel
retrieves a list of employees from the database and tracks the currently selected employee. The MainViewModel defines the ShowPrintPreview command that instantiates a report with the current employee as a parameter and creates the DocumentPreviewViewModel view model instance that contains the current report. The command uses the DialogService to show the modal window with the report preview.
- MainWindow.xaml (MainWindow.xaml)
- MainViewModel.cs (MainViewModel.vb)
- DocumentPreviewViewModel.cs (DocumentPreviewViewModel.vb)