The correct way to databound input dialogs ?
Hi,
I have read the guidelines to writing input dialogs from the MSDN :
http://msdn2.microsoft.com/en-us/library/aa969773.aspx
In one of the examples they build a dialog that can be used to add/edit a margin, which is a Thickness structure. The DataContext of the dialog is set the object to be edited, and the TextBoxes are databound to each field of the structure, with the UpdateSourceTrigger="PropertyChanged".
Then, when the dialog is closed with OK, the value can be copied back into the original object that was being modified, and if the dialog is close with Cancel, nothing is done, so the original object keeps its default values.
Now the problem I am facing is that I am using the same technique with an object that is a class, not a struct. So, the original object gets updated as soon as the user starts changing the values. In case the dialog is closed with Cancel, the object still gets updated.
I thought I might update the field with UpdateSourceTrigger="Explicit", so I only update them when we click OK. But then I have to update the source manually for every field, which kind of ruins the beauty of the original technique.
Is there any proper way to do this with a reference type ?
Thanks in advance for your thoughts.
Xavier

