Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Reporting > Telerik Reporting > SL ReportView - Add Buttons & Commands

Not answered SL ReportView - Add Buttons & Commands

Feed from this thread
  • Manuel avatar

    Posted on Jan 30, 2012 (permalink)

    Hello,

    I added two Buttons to the default Silverlight ReportViewer Style.

    Now I like to bind these two Buttons to a command.
    For this I made a class which inherited from ReportViewerModel.
    Unfortunatly this will not work. The ReportViewerModel as no contstructor.
    Error Message: Telerik.ReportViewer.Silverlight.ReportViewerModel Type has no constructors defined'

    My question:
    How can I bind Commands to the two new Buttons in the Style?

    Thank you,
    Manuel

    Reply

  • Steve Steve avatar

    Posted on Feb 1, 2012 (permalink)

    Hi Manuel,

    The ReportViewerModel constructor is internal and cannot be inherited. Please elaborate what is your goal, what action do you want to perform on these new buttons you've added?

    Regards,
    Steve
    the Telerik team

    Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

    Reply

  • Manuel avatar

    Posted on Feb 1, 2012 (permalink)

    Hello Steve,

    in passed Version of the Reporting (I guess < Q2 2011) it was working without any problems.
    I do not understand why the constructor is now internal / hidden for me.

    Anyway, I am using prism.
    The ReportViewer is in one of the regions. On the left, right and top of the reportviewer I have three other regions.
    On of the Buttons will hide the other regions (make the ReportViewer fullscreen), the other button will close the ReportViewer and show the "orginal" center region.

    It would be great to bind the Commands of the TelerikViewStyle to the ViewModel.

    Thank you,
    Manuel

    Reply

  • IvanY IvanY admin's avatar

    Posted on Feb 6, 2012 (permalink)

    Hi Manuel,

    In order to bind the commands you have first to extract the ReportViewerModel from the DataContext of the ReportViewer. Once you extract it you will be able to recover the functionality from the previous version. This is a sample how to extract the ReportViewerModel:

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

    However ReportViewerModel in both Silverlight and WPF report viewers is intended for internal use by the controls and a better approach would be to add some external buttons that control the hiding/maximizing of the Report Viewer.

    Greetings,
    IvanY
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>

    Reply

  • Manuel avatar

    Posted on Feb 14, 2012 (permalink)

    Hi IvanY,

    this is a complete different approch than I used before.
    Can you create a small Demo Project please?

    Thank you,
    Manuel

    Reply

  • IvanY IvanY admin's avatar

    Posted on Feb 17, 2012 (permalink)

    Hi Manuel,

    Here is a sample on how you can use the MoveToFirstPageCommand from the ReportViewerModel:
    public partial class MainPage : UserControl
    {
        MyViewModel myViewModel;
        public MainPage()
        {
            InitializeComponent();
            this.LayoutUpdated += new EventHandler(MainPage_LayoutUpdated);
        }
     
        void MainPage_LayoutUpdated(object sender, EventArgs e)
        {
            var layoutRoot = (FrameworkElement)VisualTreeHelper.GetChild(this.ReportViewer1, 0);
            var reportViewerModel = (ReportViewerModel)(layoutRoot.DataContext);
            this.Initialize();
            myViewModel.MyCommand = reportViewerModel.MoveToFirstPageCommand;
        }
     
        void Initialize()
        {
            myViewModel = new MyViewModel();
        }
    }


    Regards,
    IvanY
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>

    Reply

  • Manuel avatar

    Posted on Feb 23, 2012 (permalink)

    Ivany,

    in your example you are using an existing command in the ReportViewModel.

    myViewModel.MyCommand = reportViewerModel.MoveToFirstPageCommand

    I don't like to override this command (MoveToFirstPageCommand), I like to add a new Command.
    How can I a new Command to the ReportViwerModel??

    Thank you,
    Manuel

    Reply

  • IvanY IvanY admin's avatar

    Posted on Feb 27, 2012 (permalink)

    Hi Manuel,

    As the constructor of the ReportViewerModel is internal it is not possible to add new commands to the view model, you can only extract it and use the existing ones. However in your case a better approach (mentioned in one of my previous posts) would be to add some external buttons that control the hiding/maximizing of the Report Viewer, as it is just a control which can be manipulated easily in your case.

    Regards,
    IvanY
    the Telerik team
    NEW in Q1'12: Telerik Report Designer (Beta) for ad-hoc report creation. Download as part of Telerik Reporting Q1 2012. For questions and feedback, use the new Telerik Report Designer Forum.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Reporting > Telerik Reporting > SL ReportView - Add Buttons & Commands
Related resources for "SL ReportView - Add Buttons & Commands"

Features  |  Documentation  |  Demos  |  Telerik TV  |  Knowledge Base  |  Code Library  |  Step-by-step Tutorial  |  Blogs  |  Whitepaper  ]