Hi,
I have a DataTable which acts as a data source to XamDataGrid. At runtime, I'm adding multiple columns to the DataTable dynamically and the columns are sorted in Alphabetical Order in DataTable. E.g. :
DataTable / XamDataGrid:
Now if I add a new column 'B' - It will be added at 2nd position and not at the end. So the DataTable will look something like this :
DataTable :
However, in XamDataGrid the new column is always added at the end, which does not maps correctly with the DataTable
XamDataGrid :
Tokyo
So, Is there anyway to make sure the order of columns in DataTable and XamDataGrid is always in Sync ?
Hello Sumit,
Thank you for your post.
I have been looking into it. I am not sure how exactly you are adding DataColumns dynamically. That I can suggest in order to be able to achieve the functionality that you are looking for is to handle LayoutUpdated event of XamDataGrid. In the event handler you can sort the Fields by its Name, by using OrderBy method of Fields collection.
I created short sample application based on your scenario to show you how you can implement this approach. Please let me know if I am missing something about your scenario and feel free to modify the sample application that I have attached with the functionality that you are using, so I can investigate it further for you.
Please let me know if you need any further assistance on the matter.
Hello,
I am just checking your progress on the issue that you are having.
If you require any further assistance please do not hesitate to ask