Posted 12 April 2021, 7:26 pm EST - Updated 29 September 2022, 12:48 am EST
List<dynamic> as itemsource
Posted by: nzd on 12 April 2021, 7:26 pm EST
Posted 14 April 2021, 10:19 pm EST
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, which ends up being an ObservableCollection, actually, the collection is not dynamic as its items aren’t dynamic. Instead, an ObservableCollection 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.