Getting Started with Stimulsoft Reports.Wpf: A Beginnerās Guide
Stimulsoft Reports.Wpf is a powerful reporting tool designed specifically for Windows Presentation Foundation (WPF) applications. It allows developers to create, design, and view complex reports within a rich user interface. This guide will walk you through the essential steps to integrate Stimulsoft into your WPF project and build your very first report. Prerequisites
Before diving into the code, ensure you have the necessary tools installed on your development machine. Visual Studio (2019 or later recommended) .NET Framework 4.5+ or .NET Core 3.1 / .NET 6.0+
Stimulsoft Reports.Wpf libraries (available via NuGet or the Stimulsoft installer) Step 1: Create a New WPF Project
To begin, you need a standard WPF application to host the reporting components. Open Visual Studio. Select Create a new project. Choose WPF Application (C#) and click Next.
Name your project (e.g., StimulsoftWpfDemo) and select your preferred .NET version. Click Create. Step 2: Install Stimulsoft NuGet Packages
The easiest way to add Stimulsoft to your project is through the NuGet Package Manager.
Right-click your project in the Solution Explorer and select Manage NuGet Packages. Go to the Browse tab. Search for Stimulsoft.Reports.Wpf. Select the package and click Install. Accept any license agreements or dependency prompts. Step 3: Design Your First Report Template
Stimulsoft uses a .mrt file format for report templates. You can design these templates using the standalone Stimulsoft Designer app or directly in code. For this guide, we will create a simple report layout using the designer. Open the Stimulsoft Designer application. Click New Report.
From the components toolbox on the left, drag a Text box onto the page template.
Double-click the text box and type: “Hello, Stimulsoft Reports.Wpf!”
Save the report as MyFirstReport.mrt inside your project’s root folder.
In Visual Studio, select the file and change its properties: Build Action: Content Copy to Output Directory: Copy if newer Step 4: Add the Report Viewer to Your UI
Now, let’s add the Stimulsoft Viewer component to your main application window so users can see the report.
Open your MainWindow.xaml file and update the code to include the Stimulsoft namespace and the viewer control:
Use code with caution. Step 5: Load and Display the Report via Code
The final step is to write the C# logic that loads the .mrt template file, compiles it, and displays it inside the viewer.
Open MainWindow.xaml.cs and add the following code to the window constructor or loading event:
using System; using System.Windows; using Stimulsoft.Report; namespace StimulsoftWpfDemo { public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); LoadReport(); } private void LoadReport() { try { // 1. Create a new report object StiReport report = new StiReport(); // 2. Load the saved report template file report.Load(“MyFirstReport.mrt”); // 3. Render the report (compiles the template with data) report.Render(false); // 4. Assign the rendered report to the viewer control ViewerControl.Report = report; } catch (Exception ex) { MessageBox.Show($“Error loading report: {ex.Message}”); } } } } Use code with caution. Step 6: Run Your Application
Press F5 in Visual Studio to build and run your application. A window will open featuring the full Stimulsoft Report Viewer toolbar, displaying your “Hello, Stimulsoft Reports.Wpf!” report. From this built-in menu, you can instantly print the document or export it to formats like PDF, Excel, and Word. Conclusion
You have successfully integrated Stimulsoft Reports.Wpf into a desktop application. From here, you can explore advanced features like binding live SQL databases, mapping complex JSON data, adding interactive charts, and launching the runtime report designer directly inside your app to let users customize their own layouts. If you want to take this further, tell me:
Do you need to connect this report to a database or JSON data?
Are you deploying this on .NET Framework or modern .NET (.NET ⁄8)?
I can provide the specific code snippets you need to advance your project.