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
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
8 Answers, 1 is accepted
0
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
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!
0

Manuel
Top achievements
Rank 1
answered on 01 Feb 2012, 08:13 PM
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
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
0
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:
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
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 >>
0

Manuel
Top achievements
Rank 1
answered on 14 Feb 2012, 03:41 PM
Hi IvanY,
this is a complete different approch than I used before.
Can you create a small Demo Project please?
Thank you,
Manuel
this is a complete different approch than I used before.
Can you create a small Demo Project please?
Thank you,
Manuel
0
Hi Manuel,
Here is a sample on how you can use the MoveToFirstPageCommand from the ReportViewerModel:
Regards,
IvanY
the Telerik team
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 >>
0

Manuel
Top achievements
Rank 1
answered on 23 Feb 2012, 03:41 PM
Ivany,
in your example you are using an existing command in the ReportViewModel.
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
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
0
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
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.
0

zsy zsy
Top achievements
Rank 1
answered on 13 Apr 2015, 06:22 AM
Its OK