Skip to main content

Configure a Report in the Visual Studio Designer

  • 5 minutes to read

This help topic explains how to generate a data-bound report in the DevExpress Report Designer for Visual Studio and then display it in the PDF Viewer for .NET MAUI.

Resulting app

View Example

Prerequisites

To use the Report Designer in the Visual Studio, ensure that the DevExpress components installer has at least one of Reporting for options selected:

Install reporting tools

Create a .NET MAUI App

Follow instructions in the following section to create an app with our .NET MAUI components included: Create Your First App with DevExpress Mobile UI for .NET MAUI (Visual Studio for Windows). Name the project MauiReportingApp.

Note that the DevExpress library for .NET MAUI targets only Android and iOS platforms (See also: Supported Platforms).

Add a Windows Targeting Project

You need to add an auxiliary project to use the Report Designer in your solution that includes a .NET MAUI project. The Report Designer can run in projects that target net8.0 or net8.0-windows; meanwhile, DevExpress controls for .NET MAUI only target net8.0-ios and net8.0-android.

  1. Right-click the solution in the Solution Explorer, select AddNew Project…:

    Add auxiliary project

  2. Select the Class Library project template and click Next:

    Create a class library project

  3. Name the newly-created project as TestClassLibrary and click Next:

    Create a class library project

  4. On the next page, select the .NET 8.0 framework and click Create:

    Specify the project framework

Add a Report Item to the Project

Follow steps in this section to generate a report in the Report Designer.

  1. Add the DevExpress.Reporting.Core NuGet package to the TestClassLibrary project.

  2. Right-click the TestClassLibrary project in the Solution Explorer, select AddNew Item…:

    DevExpress Reporting and .NET MAUI PDF viewer - Add a new item to the project

  3. Select the DevExpress v24.2 Report template and name the resulting report class as SampleReport.

    DevExpress Reporting and .NET MAUI PDF viewer - Add report and specify its name

  4. After the report class is created, the Report Wizard is invoked. Select the Blank option and click Finish.

    DevExpress Reporting and .NET MAUI PDF viewer - Select the blank report type

  5. This will display a Report Designer with a blank report. The designer surface is broken down into bands that help you build report flow. A band can appear at the beginning or end of the report, on every printed page, once for each data record, and so on.

    DevExpress Reporting and .NET MAUI PDF viewer - The report designer

Generate a Report

In this tutorial, a report will be generated based on a list of data items (CountryDataSource). Create a Data folder with CountryDataSource and CountryData classes in it.

Show CountryDataSource implementation
namespace MauiReportingApp.Data {
   public class CountryDataSource : List<CountryData> {
       public CountryDataSource() {
           List<CountryData> sales = new List<CountryData>() {
               new CountryData(1, 0, "Norway", 385207),
               new CountryData(2, 0, "Sweden", 528447),
               new CountryData(3, 0, "Denmark", 42951),
               new CountryData(4, 0, "Finland", 338455),
               new CountryData(5, 0, "Iceland", 103000),
               new CountryData(6, 0, "Ireland", 84421),
               new CountryData(7, 0, "United Kingdom", 243610),

               new CountryData(18, 17, "Spain", 505990),
               new CountryData(19, 17, "Portugal", 92212),
               new CountryData(20, 17, "Greece", 131957),
               new CountryData(21, 17, "Italy", 301230),
               new CountryData(22, 17, "Malta", 316),
               new CountryData(23, 17, "San Marino", 61.2),
               new CountryData(25, 17, "Serbia", 88499),

               new CountryData(27, 26, "USA", 9522055),
               new CountryData(28, 26, "Canada", 9984670),

               new CountryData(30, 29, "Argentina", 2780400),
               new CountryData(31, 29, "Brazil", 8514215),

               new CountryData(34, 32, "India", 3287263),
               new CountryData(35, 32, "Japan", 377975),
               new CountryData(36, 32, "China", 9597000)
           };
           this.AddRange(sales);
       }
   }
}
namespace MauiReportingApp.Data {
   public class CountryData {
       public CountryData(int regionId, int parentRegionId, string region, double area) {
           RegionID = regionId;
           ParentRegionID = parentRegionId;
           Region = region;
           Area = area;
       }
       public int RegionID { get; set; }
       public int ParentRegionID { get; set; }
       public string Region { get; set; }
       public double Area { get; set; }
   }
}

Click the report’s smart tag and run the Design in Report Wizard… action to run the Report Wizard:

DevExpress Reporting and .NET MAUI PDF viewer - Run the report designer

Select the Table Report option and click Next:

DevExpress Reporting and .NET MAUI PDF viewer - Report wizard - Select the table report type

On the next page, select No, I’d like to specify the connection parameters myself and click Next:

DevExpress Reporting and .NET MAUI PDF viewer - Report wizard - Using an existing data connection

Select the Object data connection type:

DevExpress Reporting and .NET MAUI PDF viewer - Report wizard - Select a data connection type

On the next page, double-click the TestClassLibrary assembly and, on the next page, select the CountryDataSource data source type:

DevExpress Reporting and .NET MAUI PDF viewer - Report wizard - Select the data source type

Select the Retrieve the actual data option and click Next:

DevExpress Reporting and .NET MAUI PDF viewer - Report wizard - Retrieve the actual data

On the next page, choose the Region and Area data source fields that contain data for table columns:

DevExpress Reporting and .NET MAUI PDF viewer - Report wizard - Select data fields

Click Next to skip grouping configuration. Generally, you can select a separate data field by which table rows should be grouped.

DevExpress Reporting and .NET MAUI PDF viewer - Report wizard - Skip grouping options

On the next page, click Next to skip summary configuration:

DevExpress Reporting and .NET MAUI PDF viewer - Report wizard - Skip summary options

Specify report page settings and click Next:

DevExpress Reporting and .NET MAUI PDF viewer - Report wizard - Specify the report page settings

On the following page, select the report accent color and click Next:

DevExpress Reporting and .NET MAUI PDF viewer - Report wizard - Specify the report color

Type the report title and click Finish:

DevExpress Reporting and .NET MAUI PDF viewer - Report wizard - Define the report title

The resulting report layout looks as follows:

DevExpress Report Wizard - Resulting report

Show Report in PDF Viewer

In this tutorial, the resulting report is converted to a PDF file and then displayed in the DevExpress PDF viewer for .NET MAUI. Follow the steps below to convert the report to PDF and display it in the PDF viewer:

  1. Right-click the MauiReportingApp in the Solution Explorer, click AddProject Reference…:

    Add a project reference

  2. In the Reference Manager, select TestClassLibrary and click OK:

    Reference manager

  3. Add the PdfViewer component to the page. For more information, refer to the following section: Add a PDF Viewer to the Page.

    <ContentPage ...
                xmlns:dx="http://schemas.devexpress.com/maui">
        <dx:PdfViewer x:Name="pdfViewer"/>
    </ContentPage>
    
  4. Add the following code to the MainPage constructor to create a report, convert it to a PDF file, and open that file in the PDF Viewer:

    using DevExpress.Maui.Pdf;
    using DevExpress.XtraReports.UI;
    //...
        public MainPage() {
            InitializeComponent();
    
            SampleReport report = new SampleReport() { Name = "Sample" };
            report.CreateDocument();
    
            string resultFile = Path.Combine(FileSystem.Current.AppDataDirectory, report.Name + ".pdf");
            report.ExportToPdf(resultFile);
    
            pdfViewer.DocumentSource = PdfDocumentSource.FromFile(resultFile);
        }
    
  5. Run the project to see the results:

    Resulting app

Next Steps

To learn more about reports, refer to the following help topics in the Reporting section: