List<dynamic> as itemsource

Posted by: nzd on 12 April 2021, 7:26 pm EST

  • Posted 12 April 2021, 7:26 pm EST

    Hello,

    Is it posible to use a List with dynamic objects, as the itemsource, on grids and flexcharts?
  • Marked as Answer

    Replied 14 April 2021, 10:19 pm EST

    Hi Nikolas,

    You can use a dynamic list as an ItemsSource but it will not work properly. This is because to determine the columns, firstly it is necessary to determine the type of the items. When the collection is generic and the type is different from the object, it uses that type to generate the columns, but if the generic type cannot be determined or it is an object, the first element of the collection is used. Otherwise, it wouldn't be possible to generate the columns for non-generic collections.

    In the code it is using ObservableCollection<dynamic>, which ends up being an ObservableCollection<object>, actually, the collection is not dynamic as its items aren't dynamic. Instead, an ObservableCollection<ExpandoObject> can be used to hold the dynamic items.

    Please refer to the sample attached for reference.

    Note that the columns will not be automatically generated in this case.

    Regards,
    Ashwin

    TOAD_FlexGrid_ObservableCollection_dynamic.zip
Need extra support?

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

Learn More

Forum Channels