protected void WndClosing(object sender, CancelEventArgs e) { Window wnd = sender as Window; wnd.Closing -= WndClosing; WndSettingsParams fs = _Context[wnd]; _Context.Remove(wnd); SaveControlSettings(fs.Control, fs.SettingName, fs.Settings); }
public void SetControlSettings(TControl control, string settingName, SettingsBag <TSettings> settings, bool saveOnClose) { LoadControlSettings(control, settingName, settings); if (saveOnClose) { Window wnd = UIHelper.FindAncestorOrSelf <Window>(control, null); wnd.Closing -= WndClosing; wnd.Closing += WndClosing; var fs = new WndSettingsParams() { Settings = settings, SettingName = settingName, Control = control }; _Context[wnd] = fs; } }