I am using xamwebgrid for which I have to create columns dynamically. I have a scenario wherein when I change selection in dropdown, I need to bind the xamwebgrid with a List whose type is different from the first list that is bound to the datagrid. So before assigning the itemssource I need to again create columns for the same grid as the properties in the second type are different. So I clear the columns(grid.Columns.Clear()) and add the new columns that have different Key from the first columncollection. But as I am doing this on the same instance of xamwebgrid, it is still bound to the old itemssource. So the properties in my itemssource and columns key do not match and I get an exception. I tried setting the itemssource to null. But it still has a count. Is there anyway I can resolve this?
Hello,
Thank you for your post. I have been looking into it and I created a sample project for you with the functionality you want. Basically I set the XamGrid’s AutoGenerateColumns Property to false and used Dispatcher to add the Column. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.
Hi Stefan,
Thanks for your reply. I see that you are creating the columns after setting the itemssource. I am already using this workaround and for me this works without the displatcher. But due to my requirement where I am making two async service calls (one which fetches the data and the other which fetches the column information required in the grid) I have to wait till both service calls are completed and only then I can bind my grids itemssource and then create columns one after the other. I would like to build columns and bind the data when the respective data calls are complete to increase the response time.
I forgot to mention I am working on silverlight 4 and using xamwebgrid v10.3 version.