This is a migrated thread and some comments may be shown as answers.

Binding Report to Data from a ViewModel

1 Answer 230 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Michele
Top achievements
Rank 1
Michele asked on 03 May 2011, 10:40 AM
Hi,
I'm trying to use the evaluation version of telerik Reporting and I've this kind of problem.
I need to show into the report some data (busines objects) from a ViewModel of mine.

I mean:
I have a view with a reportViewer :

 

 

 

    <telerik:ReportViewer x:Name="ReportViewer1" Report="{Binding DataContext.Report, ElementName=this}" />

 

In its code behind I set the datacontext to the ViewModel:

 

 

    this.DataContext = new myViewModel();

 


Now the problem is:
in myViewModel I have the property "Report" as Telerik.Reporting.Report
and also another property "MyProp" (string) that I need to show into the Report

Is it possible to do that and what is the way?
I mean: how have I to set the textBox in the report ?

thanks in advance
Michele Semprini

1 Answer, 1 is accepted

Sort by
0
Chavdar
Telerik team
answered on 09 May 2011, 05:27 PM
Hello Michele,

One possible way for achieving the desired behavior is to use a report parameter. You can add a report parameter as described in the documentation and then use an expression for the Value property of the TextBox item, for example, "=Parameters.MyProp". The value of the report parameter can be set programmatically and this should be done either before the xaml's binding expression is evaluated or if it is set later then you should make sure to notify that the Report property of the model has changed (i.e. with the NotifyPropertyChanged("Report") method of the INotifyPropertyChanged interface) .

Hope this helps.

Best wishes,
Chavdar
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
Tags
General Discussions
Asked by
Michele
Top achievements
Rank 1
Answers by
Chavdar
Telerik team
Share this question
or