1

In Windows Form application, it was as trivial as Creating a Form and bind the RPT file to the Form. Looks like this option isn't possible with WPF.

I would like to show a Crystal Report on a new Window when a button is clicked. How to achieve this with WPF.

Shamim Hafiz - MSFT
  • 21,454
  • 43
  • 116
  • 176

2 Answers2

0

What version of Visual Studio are you using? If VS2010, there is a WPF CrystalReportViewer available for download.

Bob Kaine
  • 11
  • 2
0

It can be done by using the Window Class:

See code below for demonstration

MyWindowType myReport = new MyWindowType(); // create a window, MyWindow is an User Control of type Window, that is it extends Window

MyCrystalReport myReport = new MyCrystalReport();
// Do necessary modifications to myReport such as Add Data and Send Parameters
CrystalReportViewer rptViewer = new CrystalReportViewer(); // Construct a ReportViewer
WindowsFormsHost host = new WindowsFormsHost(); // Create a WindowsFormsHost
rptViewer.ReportSource = myReport; // Add Report to ReportSource 
host.Child = rptViewer; // Add report viewer as child to host
myReport.reportGrid.Children.Add(host); // Add host to MainWindow, that is myReport in this example
myReport.BringIntoView();
myReport.Show();
Shamim Hafiz - MSFT
  • 21,454
  • 43
  • 116
  • 176