Infragistics (R) NetAdvantage(R) Reporting
Using the XAML Report Viewer
Send Feedback

Glossary Item Box

Topic Overview

Purpose

This topic introduces the basics for using the XAML Report Viewer control.

In this topic

This document contains the following sections:

Adding the Report Viewer

Introduction

This procedure shows you how to add the Report Viewer to your SL/WPF application.

Overview

Following is a conceptual overview of the process:

  1. Adding the Report Viewer by Drag-and-Drop
  2. Adding the Report Viewer by adding a tag to XAML code

Steps

  1. Add the Report Viewer by Drag-and-Drop.

    In the MainPage.xaml file, drag and drop the XamReportViewer control from the Report Toolbox to the XAML Design View. This will automatically add a reference to required assemblies (e.g. InfragisticsSL4.Controls.Reports in Silverlight) and a default namespace for using NetAdvantage Reporting controls. The report viewer tag is also automatically added in the XAML code (i.e. <ig:XamReportViewer/>).

  2. Add the Report Viewer by Adding a Tag to the XAML Code.

    In XAML:

    <igReports:XamReportViewer Name="xamReportViewer1" 
    Margin="0,130,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" />

    Note: You need to add a namespace (to make report controls available in the code editor) and a reference in your Application to the required assemblies (e.g. In Silverlight: InfragisticsSL5.Controls.Reports). For example, xmlns:ig=http://schemas.infragistics.com/xaml/controls/reports

    After the Report Viewer has been added, the code should look as in the example below.

    In XAML:

    
    <UserControl x:Class="ReportSample.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        d:DesignHeight="300" d:DesignWidth="400" 
    xmlns:ig="http://schemas.infragistics.com/xaml/controls/reports" >
        <Grid x:Name="LayoutRoot">
           <ig:XamReportViewer Name="xamReportViewer1" Margin="0,130,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" />
        </Grid>
    </UserControl>
    

Assigning Reports

To assign a report means to indicate in the properties of the Report Viewer control the report to be displayed, and, in server-side rendering scenarios, the service that will be providing it. To do this, you need to specify the following properties using the Properties Panel or the code editor.

Note: The ServiceEndpointUri is required only for server-side rendering.

Working with a stream

When working on the client-side, Client render settings include a property named DefinitionStream.

The example below assumes you are binding to View Model and have a property (reportStream) returning a stream.

In XAML:

<ig:XamReportViewer Name="xamReportViewer1">
  <ig:XamReportViewer.RenderSettings>
    <ig:ClientRenderSettings DefinitionStream="{Binding ReportStream}"/>                 
    </ig:ClientRenderSettings>
  </ig:XamReportViewer.RenderSettings>
</ig:XamReportViewer>

First open and read the stream, then you assign it to the RenderSettings property of your Report Viewer.

In C#:

ClientRenderSettings renderSettings = new ClientRenderSettings();
renderSettings.DefinitionStream = File.OpenRead(@"C:\Reports\Report.igr");
myViewer.RenderSettings = renderSettings;

Note: Once used, the stream is automatically disposed of by the viewer.

Binding to a Data Source

You can configure Report Data Sources directly in your XAML code by adding the DataSource tag. The following code sample shows how to bind data to a target data source (Orders) defined in the report.

In XAML:

<ig:XamReportViewer HorizontalAlignment="Right" Margin="0,78,0,0" Name="xamReportViewer1" VerticalAlignment="Top">
  <ig:XamReportViewer.RenderSettings>
    <ig:ClientRenderSettings DefinitionUri="ReportLibrary;component/MyReport.igr, ReportLibrary" >                 
      <ig:ClientRenderSettings.DataSources>                    
        <ig:DataSource TargetDataSource="Orders" ItemsSource="{Binding ElementName=domainDataSource}" />                   
      </ig:ClientRenderSettings.DataSources>             
    </ig:ClientRenderSettings>
  </ig:XamReportViewer.RenderSettings>
</ig:XamReportViewer>

Binding Report Parameters

You can bind or set parameter values directly in your XAML code by using the parameter tag. The following code sample shows how to set the value (myvalue) of a report parameter named “parameter1”.

In XAML:

<ig:XamReportViewer HorizontalAlignment="Right" Margin="0,78,0,0" Name="xamReportViewer1" VerticalAlignment="Top">
  <ig:XamReportViewer.RenderSettings>
    <ig:ClientRenderSettings DefinitionUri="ReportLibrary;component/MyReport.igr" >                  
      <ig:XamReportViewer.Parameters>
        <!-- Seting parameter value -->
        <ig:Parameter ParameterName="parameter1" ParameterValue="myvalue"/>
      </ig:XamReportViewer.Parameters>
    </ig:ClientRenderSettings>
  </ig:XamReportViewer.RenderSettings>
</ig:XamReportViewer>

Related Topics

©2012. All Rights Reserved.