Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
275
Binding in XamReportViewer(for Chart control)
posted

Hi,

I am using a MVVM pattern with wpf, I am exploring a XamReportViewer but can't find any sample on "How to bind Data with chart in Report" .

Kindly looking forward for any samples/tutorial  or details

 

Parents
No Data
Reply
  • 3070
    posted

    Hi,

    You can bind the data in your view model to your report using the DataSources collection of the ClientRenderSettings. Check this document for sample code of how to bind a data sources through the viewer API.

    Essentially what you need to do is:

    (1) Create a report, define a data source (let’s call it ChartDS) and associate it to the chart you want to render.

    (2) In your App, add the XamReportViewer and configure it to render the report you have created

    (3) Configure the DataSources property to bind ChartDS to data in your view model. E.g.

     

    <ig:XamReportViewer>

      <ig:XamReportViewer.RenderSettings>

        <ig:ClientRenderSettings DefinitionUri="MyApp;component/Report.igr, MyApp" >                

          <ig:ClientRenderSettings.DataSources>                   

            <ig:DataSource TargetDataSource="ChartDS" ItemsSource="{Binding chartData}" />                  

          </ig:ClientRenderSettings.DataSources>            

        </ig:ClientRenderSettings>

    </ig:XamReportViewer>

     

    Assuming that “chartData” is a property in your view model.

    You can check these two documents (one and two) for how to work with Charts.

    Does this answer your question?

    Best,

    Leo

Children