I am using the XamDataGrid and letting it auto generate fields based on my objects. I call SaveCustomizations on exit and then was calling LoadCustomizations on startup. I found that the Load call wasn't working (as it didn't load the saved column order and such). So i figured it was because the FieldLayout wasn't generated yet so i handled the FieldLayoutInitialized event and called it there, still no luck. Then i noticed the generated field layouts have a GUID name and thought the names must not be matching so i named the FieldLayout in the Initialized handler, still no luck. So then I handled the loaded event and tried calling it from there, still no luck. Finally instead of making the direct call to LoadCustomizations in the loaded event i put it on the dispatcher with priority ContextIdle. And after all of that it seems to work. I don't see this documented so i am thinking I am doing something wrong.
Here is what I had to do to get it to work
Handle FieldLayoutInitialized and give new FieldLayout a key other than the GUID one
Handle LoadedEvent and dispatch LoadCustomizations call back to myself.
Hello John,
Thank you for the feedback. Please do not hesitate to let me know if you have any further questions.
Thats OK. It would take awhile to put a sample together to reproduce as my usages is pretty complex. I have my workaround working so I don't need anything else. Thanks for all your help.
Thank you for the feedback. In order for me to be able to further investigate this matter for you, would you please modify the sample application I have attached with one of my previous responses, with the functionality you are using, so the sample shows the issue.
This way I would be able to further investigate this matter for you.
Looking forward to hearing from you.
Like I said before, I worked around it by not having an empty binding. I had tried moving the call into the loaded event but that seemed to only work when there were a small number of fields. My actual application has about 200 fields and didn't work there.
I have been looking into your latest post.
What I can suggest is to move the load of the customizations in the Loaded event of the XamDataGrid. As the Field used the binding to bind to the data, the binding is overriding the settings from the file, that loads. When you place the loading of the customizations in the Loaded event of the XamDataGrid the binding would be created and then the saved settings would get loaded.
Please do not hesitate to let me know if you have any further questions on this matter.