I've just updated to xamDataGrid 2009 vol 2 and am revisiting the LoadCustomizations/SaveCustomizations behaviors that I couldn't get working to my satisfaction with previous versions.
The simple example is I have a grid with movable columns. If I move a column and SaveCustomizations to the user.config (I can see that the xml represents the new order), then create the usercontrol that holds the grid again and LoadCustomizations using the saved settings I can see that:
1. prior to the load the SaveCustomizations returns the columns in the orginally defined order,
2. the saved xml has the changed order
3. but if execute LoadCustomizations with the changed order and then execute SaveCustomizations immediately afterwards the values are in the originally defined order. Also the grid displays with the columns in the originall defined order.
I've tried LoadCustomizations in both the usercontrol_loaded event and the datagrid_FieldLayoutInitializing event and it doesn't make a difference. I've set AutoFit=false and autofitmode=default and the behavior never changes. I've even removed AutoFit and AutoFitMode and the behavior doesn't change. Do LoadCustomizations & SaveCustomizations no longer work?
I was able to reproduce an issue with the save/load but I'd like to ensure its the same issue you're encountering. Can you provide a sample demonstrating the issue you're encountering so we can be sure to address all aspects of this problem?
Hi Andrew,
Through experimentation I've finally been able to make it work. It looks like a timing issue connected with when the data is actually bound even though the columns are defined in the xaml. I've been able to make it work consistently by restoring the settings in the FieldLayoutInitialized event.
I'm enclosing sample code where you can comment/uncomment the call to the RestoreSettings method to see what I mean. Our app is much more complicated than this sample in that were using MVVM and passing in the data collections as part of the the ViewModel into the usercontrol (and of course the usercontrol is dynamically created at run-time) , all of the binding is defined in the xaml and the user can change the contents of the collection via filtering options that re-load the collections so the sequence of events is important. Probably a worst-case scenario of combinations and the timing of events.
If nothing else I think there needs to be some mention in the doc of when to best "LoadCustomizations" in your code.
Glenn