Skip to content

Avalonia Viewer

Peter Gill edited this page Jun 8, 2026 · 3 revisions

Avalonia Report Viewer

The Majorsilence.Reporting.UI.RdlAvalonia package provides a cross-platform report viewer built on Avalonia UI. It runs on Windows, Linux, and macOS and renders reports using SkiaSharp.

The viewer control includes a built-in toolbar with open, save, print (export to PDF), zoom, page navigation, and parameter input.

Install

dotnet add package Majorsilence.Reporting.UI.RdlAvalonia

Basic usage

Add the viewer to an Avalonia Window or UserControl:

<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:rdl="clr-namespace:Majorsilence.Reporting.UI.RdlAvalonia.Viewer;assembly=Majorsilence.Reporting.UI.RdlAvalonia"
        Title="Report Viewer" Width="1024" Height="768">
    <rdl:AvaloniaReportViewer x:Name="ReportViewer" />
</Window>

Load a report in the code-behind:

using Majorsilence.Reporting.Rdl;
using Majorsilence.Reporting.UI.RdlAvalonia.Viewer;

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();

        // One time per app instance
        RdlEngineConfig.RdlEngineConfigInit();

        Opened += async (s, e) => await LoadReportAsync();
    }

    private async Task LoadReportAsync()
    {
        await ReportViewer.SetSourceFileAsync(new Uri(@"/path/to/report.rdl"));
    }
}

API

Member Description
SetSourceFileAsync(Uri) Load a report from an .rdl file path.
SetSourceRdlAsync(string) Load a report from an RDL XML string.
RebuildAsync() Re-render the current report (e.g. after changing parameters).
SetReportParametersAmpersandSeparated(string) Set parameters using name=value&name2=value2 format before calling RebuildAsync().
ConnectionStringOverride Replace the data source connection string at runtime.
OverwriteSubreportConnection Apply ConnectionStringOverride to sub-reports as well.
WorkingDirectory Base directory for resolving relative sub-report paths.
SubreportDataRetrieval Event fired when a sub-report needs data — use to supply a DataTable programmatically.

With parameters

ReportViewer.SetReportParametersAmpersandSeparated("StartDate=2024-01-01&EndDate=2024-12-31");
await ReportViewer.SetSourceFileAsync(new Uri(@"/path/to/report.rdl"));

With a connection string override

ReportViewer.ConnectionStringOverride = "Server=myserver;Database=mydb;Integrated Security=true";
await ReportViewer.SetSourceFileAsync(new Uri(@"/path/to/report.rdl"));

Font requirements on Linux / macOS

See Linux — PDF export and Fonts.

sudo apt-get install -y fonts-liberation fontconfig && sudo fc-cache -f -v

Clone this wiki locally