Data Binding using External Objects

Posted by: fsl on 28 January 2020, 4:46 pm EST

    • Post Options:
    • Link

    Posted 28 January 2020, 4:46 pm EST

    I’m using this method copied (more or less) from

    C1FlexReport _report = new C1FlexReport();
    List<OrderListItem> outstandingOrders = Wibble.Services.OrderService.GetOutstandingOrders(dateFrom: null, dateTo: null);
    using (Stream stream = Services.ReportService.GetFlexReportDefinition("Reports"))
        _report.Load(stream, "Report1");
    _report.DataSource.Recordset = outstandingOrders;

    The report is found in the assembly at runtime ok but

    _report.DataSource.Recordset = outstandingOrders;

    fails with the error

    System.NullReferenceException: ‘Object reference not set to an instance of an object.’

    C1.Xaml.FlexReport.C1FlexReport.DataSource.get returned null.

    DataSource = null. I can’t see where in the docs it shows how to initialize the DataSource. What am I missing?

  • Posted 30 January 2020, 11:38 pm EST


    I have attached two applications:

    1. Library_MVVM, this is a library implemented in MVVM pattern.
    2. MVVMLib_UWPFlexRpt, this is an UWP application binding C1FlexReport in code to the data present in above library.

    Please verify your code w.r.t above application and share with us your observations. Hopefully the above samples will help you meet your requirement.

    Thanks & best wishes,


  • Posted 1 February 2020, 2:44 pm EST

    Thank you Ruchir. We can now bind a collection to a report. The key was to set the DataSource of the report in the report designer to Main.

    The report does not show the properties of the collection. How do we access the properties of the collection from within the report designer in order to design the layout of the report and bind controls to collection properties?

  • Posted 2 February 2020, 4:32 pm EST


    Glad that you can bind the report to the data source.

    Regarding accessing the properties from report designer, like mentioned over the other case:, I am discussing it with developers and will update you with the information I receive.

    Best wishes,


  • Posted 14 April 2020, 3:14 pm EST

    Hi Ruchir

    Any progress regarding viewing the properties of the viewmodel from report designer? We bind the data source to the report then save the report definition as below but when viewed in the report designer the report definition does not contain the properties of the viewmodel

    _report.Load(stream, "Report1");
    _report.DataSource.Recordset = statementViewModel;
    FileSavePicker picker = new FileSavePicker();
    picker.FileTypeChoices.Add("Files report (*.flxr)", new System.Collections.Generic.List<string>() { ".flxr" });
    picker.SuggestedStartLocation = PickerLocationId.ComputerFolder;
    StorageFile storageFile = await picker.PickSaveFileAsync();
    await _report.SaveAsync(storageFile);

    We need to be able to see the properties of the viewmodel in the report designer. What are we doing wrong here?

  • Posted 15 April 2020, 5:20 pm EST


    In your other query [] I posted an application that contained nested properties and showed how to set the report data source to the ViewModel. The application I shared targets UWP and Net4.6 but, C1FlexReportDesigner is released for Net4 and Net4.5.2 so you can’t use C1FlexReportDesigner application distributed with ComponentOne. ComponentOne provides a demo FlexReportDesigner you can find it here:

    It uses the same code as C1FlexReportDesigner so you can build it manually for Net6.0.

    *Also when build please add reference to

    System.Reflection.TypeExtensions 4.6.0 nuget package, it is required because Library_MVVM is not a trivial WinForms library.

    Please try the above and if still you face any problem, please share your stripped application for us to investigate.



  • Posted 15 April 2020, 8:04 pm EST

    Thank you Ruchir. I’m not sure if we are talking about the same thing here. I save a report definition using

    await _report.SaveAsync(storageFile);

    I’m not trying to use the designer to connect to the data source. I’m trying to bind the data source in C# then save the report definition with the bound data source so that I can then open it in the designer. When I open the report in the designer I want to see the data source properties so they can be arranged on the report.

    Are you saying the reason I do not see the data source saved with the report when I open that report with the report designer is due to an issue with the report designer?

  • Posted 23 April 2020, 5:38 pm EST


    Apologies for the delayed response and kindly neglect my previous response, I had it misinterpreted.

    From what I now understand, you are binding the FlexReport to a data-source in code-behind and saving its report definition. Then, upon loading this report definition in report designer, you expect the designer to show the data-source properties?

    If it is so, I would like to inform you that it is by-design. This is because the data source was assigned in code-behind so the designer would not know the properties of the data-source. It would just be the earlier layout that you had created using the designer.

    If there is something else you are expecting, please elaborate.

    Thanks & regards,

  • Posted 23 April 2020, 7:33 pm EST

    Thank you Ruchir. Just to be sure I understand correctly, if we bind the datasource to the report and then save the report as a .flxr file like this

    _report.DataSource.Recordset = statementViewModel;
    await _report.SaveAsync(storageFile);

    the report definition does not include the data source? What does SaveAsync do?

  • Posted 24 April 2020, 10:49 pm EST

    The method saves the current report definition to a file as mentioned here:



  • Posted 25 April 2020, 7:38 am EST

    When you save a flexreport in the designer it also saves the data source as part of the report definition. Correct?

    A flxr file is an xml file. The DataSource is an element in the xml file


    The report designer is a UI over creating the report definition in code. We create a report definition file in code then save it. The report definition includes the data source. According to the SaveAsync docs

    This method does not embed pictures and subreports into the output file. It only saves subreport names and saves images in external files.

    The docs say nothing about not saving the data source. If the docs are correct, it should save the data source. Can you please confirm if the docs are correct?

  • Posted 28 April 2020, 7:09 pm EST


    Just wanted to update you that we are further investigating this scenario. We will get back to you with more information on this.



  • Posted 30 April 2020, 12:46 pm EST

    You may find this helpful; in our current report writer we do something like

    await report.SaveAsync(storageFile);

    This then creates a report definition file with the data source defined like this

    <StatementViewModel Ref="2" type="Stimulsoft.Report.Dictionary.StiBusinessObject" isKey="true">
      <BusinessObjects isList="true" count="2">
        <Statements Ref="3" type="Stimulsoft.Report.Dictionary.StiBusinessObject" isKey="true">
          <BusinessObjects isList="true" count="1">
            <Orders Ref="4" type="Stimulsoft.Report.Dictionary.StiBusinessObject" isKey="true">
              <BusinessObjects isList="true" count="0" />
              <Category />
              <Columns isList="true" count="32">
              <Dictionary isRef="1" />
          <Category />
          <Columns isList="true" count="6">
          <Dictionary isRef="1" />
        <LetterheadImage Ref="5" type="Stimulsoft.Report.Dictionary.StiBusinessObject" isKey="true">
          <BusinessObjects isList="true" count="1">
            <Dispatcher Ref="6" type="Stimulsoft.Report.Dictionary.StiBusinessObject" isKey="true">
              <BusinessObjects isList="true" count="0" />
              <Category />
              <Columns isList="true" count="2">
              <Dictionary isRef="1" />
          <Category />
          <Columns isList="true" count="0" />
          <Dictionary isRef="1" />
      <Columns isList="true" count="7">
      <Dictionary isRef="1" />

    There is no need for the developer to specify types, only the viewmodel need be specified and the report designer is able to read the types from the viewmodel.

    The report definition can then be given to our design team for layout. They can see the viewmodel properties in the report designer where they can drag and drop properties onto the design surface.

    That’s what we are hoping to be able to do with Flexreports.

  • Posted 3 May 2020, 8:50 pm EST


    I understand your requirement but could you please share a small application demonstrating each step you are following in your application (that is, with the statementViewModel, the code behind where you are setting report’s DataSource, the report definition file etc). If needed, it would help us escalate your requirement and brief the developer more properly and help you effectively.



  • Posted 31 May 2020, 11:49 am EST

    My apologies for the delay in responding Ruchir. My company has been on skeleton staff during Covid and I was required to take leave. This is my first day back at work.

    I have created a demo app at!AiGVkyOWwr6Jx0jZjvBXMvzqHK03?e=bnXjbp

    The app shows how our current report writer, Stimulsoft, creates a report definition file from the StatementViewModel. The resultant report definition file Statement.mrt is xml.

  • Posted 1 June 2020, 11:22 pm EST

    Thank you for the application.

    I am going to forward it for further investigation and will get back to you as soon there is a solution/information.


  • Posted 15 July 2020, 5:19 pm EST


    The developer has shared that it is not possible, FlexReport does not support the same scenario as StiReport.

    We are sorry for the inconvenience caused due to this.


Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels