ActiveReports 17 .NET Edition
Developers / Create Applications / .NET Viewer Application / WPF Viewer / Load Reports
In This Topic
    Load Reports
    In This Topic

    To load and display a report using the Viewer control in a WPF application,

    1. Create a new a WPF application in Visual Studio.
    2. From the Visual Studio toolbox, drag the Viewer control onto your XAML Form.
    3. Set the viewer's Dock property to Fill to show the complete Viewer control on the Form.
    4. In the Solution Explorer, select the report you have created and from the Properties window, set Copy to Output Directory to Copy Always.

      Note: If Page/RDL report is selected from dropdown of Source property (containing relative path), 'Copy to Output Directory' for selected report should be set as 'Copy always/Copy if newer' otherwise error "Could not find file ... " appears on loading WPF Viewer.

      Caution: In WPF Viewer control, previewing code-based Section reports using Source and SourceFormat properties is not supported.

    5. On MainWindow.xaml, with the viewer selected, go to the Properties window and double click the Loaded event.
    6. In the MainWindow code view that appears, add code like the following to the viewer1_loaded event to bind the report to the viewer. This code shows an .rdlx report being loaded, but you can use an .rpx report as well.
      Visual Basic.NET code. Paste INSIDE the viewer1_Loaded event in MainWindow.xaml.vb.
      Copy Code
      C# code. Paste INSIDE the viewer1_Loaded event in MainWindow.xaml.cs.
      Copy Code


    • Refer to the LoadDocument method to see other ways to load a report in WPF Viewer.
    • We can set report for WPFViewer directly on XAML file and load the report in WPF Viewer using Source and SourceFormat properties.
    • To avoid evaluation banners appearing at run time, license your ActiveReports WPF Application project. You can find information on licensing in License Your ActiveReports


    See Also