ReportViewer for WPF

5 posts, 1 answers
  1. Alen
    Alen avatar
    3 posts
    Member since:
    Nov 2012

    Posted 04 Dec 2012 Link to this post

    For the application we're currently developing we'd like to use the Telerik Reporting.These last days I was testing it and how well it would suit our needs. Our application is running in WPF on .NET 4.0 and has its own look and feel. Now I was searching your forum on how to apply changes to the ReportViewer class and I came to know that you have to change the style of the ReportViewer itself, which wouldn't be a big deal. Since our application has its own Ribbonbar, we wanted to remove the Toolbar from the ReportViewer and integrate it into our application. Now I've figured out that the ReportViewer has no commands which support the functionality identical to those of the integrated Toolbar. On the forum you could find out that the ReportViewer was implemented using the MVVM-pattern.
    So I'd like to know if there is a way to accomplish the needed task? Am I able to access the commands of the ReportViewerModel from ReportViewer (e.g. MoveToNextPageCommand, etc.) or do I have to write my own UserControl that has a ViewModel inheriting from ReportViewerModel?
    An answer to this cause would be appreciated.

  2. Answer
    IvanY avatar
    417 posts

    Posted 07 Dec 2012 Link to this post

    Hello Alen,

    The ReportViewerModel is intended for internal purposes only and therefore the commands are not exposed so that you can easily use them. However there is an available workaround that will suite your needs - in case you use it please have in mind that the ReportViewerModel might change in a subsequent version of Telerik Reporting and you will have to manually change your code so that it works with the new version.

    The workaround is to extract the ReportViewerModel from the DataContext of the ReportViewer. Once you do that you will have access to the commands of the Report Viewer and you can invoke them in your own code. Check out the snippet below:
    var layoutRoot = (FrameworkElement)VisualTreeHelper.GetChild(this.ReportViewer1, 0);
    var reportViewerModel = (ReportViewerModel)(layoutRoot.DataContext);

    I hope that helps.

    Kind regards,
    the Telerik team

    HAPPY WITH TELERIK REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

  3. Alen
    Alen avatar
    3 posts
    Member since:
    Nov 2012

    Posted 10 Dec 2012 Link to this post

    Hello IvanY,

    thank you very much. Your answer was exactly what I needed and helped me accomplish my task.

    Kind Regards,
  4. Stefan
    Stefan avatar
    1 posts
    Member since:
    Nov 2015

    Posted 13 Jun 2018 Link to this post


    I tried the approach suggested by IvanY but can't cast layoutRoot.DataContext to a ReportViewerModel, as this class is internal.
    Is there a workaround for this?

    Best Regards!

  5. Todor
    Todor avatar
    562 posts

    Posted 18 Jun 2018 Link to this post

    Hello Stefan,

    Starting with Q3 2014, the WPF ReportViewer's ReportViewerModel is internal and should NOT be used. Instead you can use the exposed viewer's API.

    From Q1 2014 Telerik Reporting WPF/Silverlight ReportViewer controls use only implicit styles. For more details please refer to the Setting a theme of the WPF/Silverlight Report Viewer (Q1 2014 and later) blog post and How to: Add report viewer to a WPF application help article.

    The file related to the the viewer is the Telerik.ReportViewer.Wpf.xaml from the proper theme - for example C:\Program Files (x86)\Progress\Telerik Reporting R2 2018\Wpf\Themes\ExpressionDark. It can be customized according to your needs. The commands can be  bound to custom buttons -  check the default code of Telerik.ReportViewer.Wpf.xaml for hints on implementation.

    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top