This section explains you the steps required to create your first WPF reporting application to display an already created SSRS RDL report in the Bold Reports WPF Report Viewer without using a Report Server.
Open Visual Studio 2017 and select File > New > Project.
Go to Installed > Visual C# > Windows Desktop, and then select the required .NET Framework in the dropdown.
Select the WPF App (.NET Framework), change the application name, and then click OK.
Right-click the project or solution on the Solution Explorer tab, and choose Manage NuGet Packages. Alternatively, select Tools > NuGet Package Manager > Manage NuGet Packages for Solution.
Refer to the NuGet Packages to learn more details about installing and configuring Report Viewer NuGet packages.
Search for BoldReports.Wpf
NuGet package, and install them in your WPF application.
Package | Purpose |
---|---|
BoldReports.Wpf |
Contains WPF Reporting controls (Report Viewer and Report Writer) to preview and export the reports. |
Import the Report Viewer namespace as shown below in the MainWindow.xaml
file,
xmlns:syncfusion="clr-namespace:BoldReports.UI.Xaml;assembly=BoldReports.Wpf"
Initialize the Report Viewer component inside the <Grid>
tag as shown below in the MainWindow.xaml
file,
<Window
.....
.....
.....
.....
xmlns:syncfusion="clr-namespace:BoldReports.UI.Xaml;assembly=BoldReports.Wpf"
.....
.....>
<Grid>
<syncfusion:ReportViewer Name="reportViewer" />
</Grid>
</Window>
The Report Viewer is only for rendering reports. You must use a report generation tool to create a report. To learn more about this, refer to the create RDL report section.
Create a folder Resources
in your application to store the RDL reports.
Add already created reports to the newly created folder.
In this tutorial, the
sales-order-detail.rdl
report is used, and it can be downloaded at this link. You can add the reports from the Syncfusion installation location. For more information, refer to the samples and demos section.
Set the Build Action
to content and Copy to Output Directory
to either Copy always or Copy if newer.
Open the MainWindow.xaml.cs
file.
Initialize the window loaded event inside the MainWindow()
constructor.
public MainWindow()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
}
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
}
Set the ReportPath
property in the MainWindow_Loaded
event and invoke the RefreshReport()
method to render the report.
You can replace the following code in your MainWindow_Loaded
event method.
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
this.reportViewer.ReportPath = System.IO.Path.Combine(Environment.CurrentDirectory, @"Resources\sales-order-detail.rdl");
this.reportViewer.RefreshReport();
}
Build and run the application to view the report output in the Report Viewer as displayed in the following screenshot.
Note: You can refer to our feature tour page for the WPF Report Viewer to see its innovative features.