This article explains the steps needed to create an application which uses the Silverlight report viewer.
- First you need to create a Silverlight project. Once you do, add references to the following assemblies in your Silverlight project:
- Telerik.ReportViewer.Silverlight.dll (located in C:\Program Files\Telerik\Reporting Q1 2012\Bin)
- System.Windows.Controls.dll
- Telerik.Windows.Controls.dll
- Telerik.Windows.Controls.Input.dll
- Telerik.Windows.Controls.Navigation.dll
The RadControls for Silverlight assemblies are located in
C:\Program Files\Telerik\Reporting Q1 2012\Examples\CSharp\SilverlightDemo\bin)
- Add the ReportViewer to the MainPage.xaml from the ToolBox either
through Visual Studio 2010 or from Expression Blend.
You should skip points #3, #4 and #5 if you have done that, as they describe how to register the report viewer manually.
- Open MainPage.xaml
- Register the namespace in the following way: xmlns:<Name of
namespace>= "<Name of assembly>" in our case
xmlns:telerik="clr-namespace:Telerik.ReportViewer.Silverlight;assembly=Telerik.ReportViewer.Silverlight"
- Now you would be able to declare the ReportViewer control:
CopyXML
<telerik:ReportViewer></telerik:ReportViewer>
- Next we need to set the ReportServiceUri
and Report properties of the viewer.
The ReportViewer..::.ReportServiceUri
should point to the Telerik Reporting WCF service:(ReportServiceUri="../ReportService.svc")
and the
ReportViewer..::.Report
should be set to the assembly qualified name of the report you want to show i.e.:(Report="Telerik.Reporting.Examples.CSharp.BarcodesReport, CSharp.ReportLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null").
Review Creating a Simple Report topic for information on creating a Telerik Report.
The MainPage.xaml should look similar:
Example
CopyXML
<UserControl x:Class="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"
xmlns:telerik="clr-namespace:Telerik.ReportViewer.Silverlight;assembly=Telerik.ReportViewer.Silverlight">
<Grid x:Name="LayoutRoot">
<telerik:ReportViewer x:Name="ReportViewer1" Width="1000"
ReportServiceUri="../ReportService.svc"
Report="Telerik.Reporting.Examples.CSharp.BarcodesReport, CSharp.ReportLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
</telerik:ReportViewer>
</Grid>
</UserControl>
See Also