I create a window in WPF. The constructor takes a “ref XmlElement settings” which is used to display information in that window.
In the constructor, I clone those settings:
_ClonedSettings = (XmlElement)settings.Clone();
and I keep a pointer to the original settings:
_OriginalSettings = settings;
The UI modifies _ClonedSettings. Then if user hits OK button, I want to overwrite the original settings with the _ClonedSettings, so the window creator gets the right values.
How do I do this final copying operation?
Don’t use a ref. Just set the settings as a public property on the window
Within the Window, update the settings and such as you’ve done. Once the window has been shown, get the settings out.
You can also set a DialogResult on your window to see what happened with the editor…