Problem getting the ReportViewerModel after upgrade to Q1'11

8 posts, 0 answers
  1. Paolo
    Paolo avatar
    394 posts
    Member since:
    Jun 2009

    Posted 16 Mar 2011 Link to this post

    before I was getting the ReportViewerModel doing so :

    var reportViewerModel = reportViewer.DataContext as ReportViewerModel;

    Today after Q1'11 upgrade I get an Enum I define in the Main page hosting it.... why this happen?

  2. Chavdar
    Chavdar avatar
    888 posts
    Member since:
    Sep 2012

    Posted 16 Mar 2011 Link to this post

    Hello Paolo,

    This change is done on purpose in order to allow binding of report viewer properties directly to an inherited DataContext (see the release notes). If you have to get the ReportViewerModel then you should use the report viewer's first child instead. Here is a sample code snippet which shows how to achieve this:

    var layoutRoot = (FrameworkElement)VisualTreeHelper.GetChild(this.ReportViewer1, 0);
    var rvm = (ReportViewerModel)(layoutRoot.DataContext);

    This works both for WPF and Silverlight report viewers.

    However the ReportViewerModel in both Silverlight and WPF report viewers is intended for internal use by the controls and we will appreciate if you share with us your particular case that demands the use of the ReportViewerModel.

    All the best,
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!

  3. PCF
    PCF avatar
    5 posts
    Member since:
    Mar 2011

    Posted 11 May 2011 Link to this post

    If it's similar to the use case I'm in right now, we need a way to refresh the report using parameters that can only be set from outside of the ReportViewer...and we're using Silverlight MVVM.

    The previous version allowed you to do this, and it worked quite well:


    Now, as you mentioned, that breaks.
    The issue with the work-around now is that my report does not have a child and the call to GetChild(ReportViewer, 0) now breaks with this error:
    Specified argument was out of the range of valid values.
    Parameter name: childIndex

    I don't want to un-upgrade all the reports but that's what I'll have to do I guess...

  4. Steve
    Steve avatar
    10942 posts
    Member since:
    Feb 2014

    Posted 16 May 2011 Link to this post

    Hi PCF,

    Here is a working sample snippet tested on our demos that illustrates this approach:

    Copy Code
    Copy Code
    public partial class MainPage : UserControl
        public MainPage()
        void button1_Click(object sender, RoutedEventArgs e)
    static class ReportViewerExtensions
        public static void RefreshReport(this ReportViewer reportViewer)
            var layoutRoot = (FrameworkElement)VisualTreeHelper.GetChild(reportViewer, 0);
            var viewerModel = (ReportViewerModel)layoutRoot.DataContext;
            var refreshCommand = viewerModel.RefreshReportCommand;
            if (refreshCommand.CanExecute(null))

    Hope it helps.

    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items

  5. Andrew Smith
    Andrew Smith avatar
    4 posts
    Member since:
    Nov 2009

    Posted 16 May 2011 Link to this post

    I was using this to hide the parameters area.

     If e.PropertyName = "IsParametersAreaVisible" _
        AndAlso CType(reportv.DataContext, ReportViewerModel).IsParametersAreaVisible _
        AndAlso m_bOverwriteReportParameters Then

          CType(reportv.DataContext, ReportViewerModel).IsParametersAreaVisible = False
          m_bOverwriteReportParameters = False
        End If

  6. Anton Swanevelder
    Anton Swanevelder avatar
    26 posts
    Member since:
    Aug 2008

    Posted 31 May 2011 Link to this post


    I am trying to make sense of how MVVM fits into the Silverlight ReportViewer but I am just too unfamiliar with Telerik Reports to make any sense of it.

    I've logged a support ticket under my account regarding, but this article seems that you are saying that the DataContext will inherit in Silverlight.

    Am I suppose to create the Report with an Objectdatasource or without, any nice walkthroughs on this just simply explaining ReportViewer, Silverlight and MVVM. I can imagine if you know what goes where it is really simple but I am unable to get any data shown in my report from my ViewModel.

    I have a report with no datasource, and set the DataContext of the Report Viewer to my Model which is an ObservableCollection of a class with Properties. I then also created a Binding on the TextBlock in the Report to a string of the Property. Pretty much what you would do in a normal RadGridView.


  7. Peter
    Peter avatar
    1557 posts
    Member since:
    Sep 2012

    Posted 31 May 2011 Link to this post

    Hello Anton,

    For now Telerik Reports reside on the server and the Silverlight ReportViewer always requires the Telerik Reporting WCF Service, which acts as a communication interface between the client (Silverlight) and the report server. Currently the reporting engine is not compatible with Silverlight and it requires .NET framework to perform its operations. Thus the report can't utilize the Silverlight's DataContext but instead rely on the datasource components that are defined in the report definition.

    You may find useful the following help resources:

    Anyway we already have a couple of ideas how to improve the integration of the Reporting engine with Silverlight, but due to some limitations of the framework we will stay with the report service for now.

    All the best,
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items

  8. facundo
    facundo avatar
    1 posts
    Member since:
    Oct 2007

    Posted 02 Feb 2012 Link to this post

    Hello Peter,

    I'm working with the Reporting WCF Services and ReportViewerModel. I want to change an exception error that I get from a WCF service call. The thing is that I have my reports in another server and I'm doing some testing regarding reports service connection, so my test consists in trying to render a report simulating a lost of service connection. Once that happens, I got a big timeout exception inside the Report Designer that I'd like to change to an user-friendly message.

    I've been using the ReportViewerModel.Error property to set my custom message in the service callback, but sometimes the Error property gets override for the original exception message.

    How could I display custom messages inside the report designer?
    How can I handle those types of custom error message?

    Thanks in advance.


Back to Top