Search code examples
dynamicbindinginfragisticsxamgrid

Infragistics XamGrid dynamic columns


I recently faced one situation where I do need to bind dynamic collection to Infragistics XamGrid where columns to be shown are not fixed. So I wanted something like ObservableCollection to be bound to list. However dynamic/Expando are not yet supported by infragistics. I tried with DataTable, it didn't work.

How this can be achieved?


Solution

  • So finally I was able to achieve it using anonymous type. If you know which columns to choose you can bind anonymous object to grid.

    Also I had a list of fields to be shown and data to be shown. To merge these I took help of Exprssion trees and type builder to build type at runtime and add properties to it, bind this new type to grid. You can get code on stackoverflow itself of expression building and dynamic type generation.