Telerik Reporting R1 2017

Manual Setup

This article explains the steps needed to manually create an application which uses the WPF report viewer. Another way to add a WPF Report Viewer to your application

  1. Create a new WPF Application project in Visual Studio.

    Note Note

    .NET Framework 4 Client Profile is not supported.

  2. Add references to the following Telerik UI for WPF NoXaml assemblies:

    • Telerik.Windows.Controls.dll

    • Telerik.Windows.Controls.Input.dll

    • Telerik.Windows.Controls.Navigation.dll

    • Telerik.Windows.Data.dll

    In case you are still not prepared to migrate to Implicit Styling you can use the binaries that include the xaml. However you will still have to add all the xaml files mentioned in the next step, otherwise the Report Viewer will not show up as it will have no style.

    In case you use Telerik UI for WPF only for the report viewer, you can use Telerik UI for WPF assemblies and XAML that we provide with the local demos. They are internally unlocked for the WPF ReportViewer but can only be used with the report viewer. The Telerik UI for WPF assemblies are located in C:\Program Files\Telerik\Reporting R1 2017\Examples\CSharp\WpfDemo\bin). The corresponding XAML resources can be found in C:\Program Files\Telerik\Reporting R1 2017\Wpf\Themes.

    The WPF ReportViewer is build with the latest official release of Telerik UI for WPF. In this way we provide trouble free upgrade for most of the users. This means that you can use the latest version of Telerik UI for WPF in your project and report viewer.

    It is possible that the Telerik UI for WPF assemblies have a greater version (service pack or internal build) than the one with which the WPF report viewer control is build. In this case you have to add appropriate assembly binding redirects (see Binding Redirects topic bellow).

    Note Note

    The files part of Telerik Reporting are the Telerik.ReportViewer.Wpf.dll and Telerik.ReportViewer.Wpf.xaml. The rest DLLs and XAML resources must be updated from Telerik UI for WPF product folder.

  3. Add the following xaml files, required for the implicit styling of the report viewer:

    • System.Windows.xaml

    • Telerik.Windows.Controls.xaml

    • Telerik.Windows.Controls.Input.xaml

    • Telerik.Windows.Controls.Navigation.xaml

    • Telerik.ReportViewer.Wpf.xaml

    The Telerik UI for WPF xaml files are located in C:\Program Files\Telerik\Reporting R1 2017\Wpf\Themes).

  4. The next step is to merge these ResourceDictionaries in the App.xaml file:

    XAML
     <Application x:Class="WpfApplication1.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml">
      <Application.Resources>
        <ResourceDictionary>
          <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/Themes/System.Windows.xaml"/>
            <ResourceDictionary Source="/Themes/Telerik.Windows.Controls.xaml"/>
            <ResourceDictionary Source="/Themes/Telerik.Windows.Controls.Input.xaml"/>
            <ResourceDictionary Source="/Themes/Telerik.Windows.Controls.Navigation.xaml"/>
            <ResourceDictionary Source="/Themes/Telerik.ReportViewer.Wpf.xaml"/>
          </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
      </Application.Resources>
    </Application>
  5. Drag and drop the ReportViewer control from the toolbox in a WPF window. If the ReportViewer is not available in the toolbox, you can add it using the instructions from the How to add the WPF ReportViewer to the toolbox topic bellow.

  6. Add reference to Telerik.Reporting.dll in your project.

  7. Set the ReportSource for the report viewer. For more information, see How to: Set ReportSource for Report Viewers. This can be done either declaratively or programmatically:

    • Specifying a report source declaratively, we would use type report source for this example:

      <Window x:Class="WpfApplication1.Window1"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          Title="Window1" Height="451" Width="683" 
          xmlns:telerik="clr-namespace:Telerik.ReportViewer.Wpf;assembly=Telerik.ReportViewer.Wpf" 
          xmlns:telerikReporting="clr-namespace:Telerik.Reporting;assembly=Telerik.Reporting">
          <Grid>
              <telerik:ReportViewer Name="reportViewer1">
                  <telerik:ReportViewer.ReportSource>
                      <telerikReporting:TypeReportSource TypeName="Telerik.Reporting.Examples.CSharp.BarcodesReport, CSharp.ReportLibrary" />
                  </telerik:ReportViewer.ReportSource>
              </telerik:ReportViewer>
          </Grid>
      </Window>
    • Setting a report source at run time. The following code snippet illustrates how to assign a report source to the WPF ReportViewer in the Window.Loaded event handler:

      <Window x:Class="WpfApplication1.Window3"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          Title="Window3" Height="328" Width="618" xmlns:my="clr-namespace:Telerik.ReportViewer.Wpf;assembly=Telerik.ReportViewer.Wpf" Loaded="Window_Loaded">
          <Grid>
              <my:ReportViewer Name="reportViewer1" />
          </Grid>
      </Window>
      namespace WpfApplication1
      {
          using System.Windows;
      
          /// <summary>
          /// Interaction logic for Window3.xaml
          /// </summary>
          public partial class Window3 : Window
          {
              public Window3()
              {
                  InitializeComponent();
              }
      
              private void Window_Loaded(object sender, RoutedEventArgs e)
              {
                  var typeReportSource = new Telerik.Reporting.TypeReportSource();
                  typeReportSource.TypeName = "Telerik.Reporting.Examples.CSharp.ListBoundReport, CSharp.ReportLibrary";
                  this.reportViewer1.ReportSource = typeReportSource;
              }
          }
      }

Binding Redirects

In case you use Telerik UI for WPF version greater than the latest official release(service pack or internal build) you have to redirect all assemblies required by the Telerik WPF ReportViewer to their latest versions. To do this, add the following bindingRedirects to your app.config and replace the "2010.1.421.35" with the exact version of Telerik UI for WPF assemblies:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Telerik.Windows.Controls" culture="neutral" publicKeyToken="5803cfa389c90ce7"/>
        <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="2010.1.421.35"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Telerik.Windows.Controls.Input" culture="neutral" publicKeyToken="5803cfa389c90ce7"/>
        <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="2010.1.421.35"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Telerik.Windows.Controls.Navigation" culture="neutral" publicKeyToken="5803cfa389c90ce7"/>
        <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="2010.1.421.35"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>
Note Note

Redirecting Assembly Versions is a standard .NET technique for resolving assembly versions conflicts. Visual Studio 2013 allows automatic binding redirects. For more details check MSDN: How to: Enable and Disable Automatic Binding Redirection.

How to add the WPF ReportViewer to the toolbox

  1. Select a WPF window file (e.g. Window1.xaml).

  2. Open the toolbox and add your own tab or click on the General tab.

  3. Right click in the selected tab area and select Choose Items… from the context menu.

  4. The previous step will open Choose Toolbox Items dialog. Select the WPF Components tab and find the ReportViewer component from the Telerik.ReportViewer.Wpf assembly.

  5. Click OK

See Also