-
I've created an extension for VS2022 that uses a custom WPF UserControl for the user to edit the settings via the Visual Studio Tools->Options window(as described in Settings & options). I'd prefer that changes not actually get saved unless the user hits the OK button for the main Tools->Options window (instead of calling Save whenever a value changes as the example code does). I assume there must be a way to do this as that is how it works if you use the BaseOptionPage/BaseOptionModel class (ie. no custom UI). Is there an Event I can handle that will be called when the user hits the OK button? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The
So you should be able to override the Just remember that only one instance of your UserControl is created, no matter how many times you open and close the Options dialog. To account for that, you may need to override some of the other methods to reset the state of your UserControl so that when you open the Options dialog, it's not populated with the changes that you previously made to it before you clicked the Cancel button. |
Beta Was this translation helpful? Give feedback.
The
DialogPage
class (whichUIElementDialogPage
inherits from) contains some methods that you can override to be notified about the different lifecycle events.OnActivate()
OnDeactivate()
OnClosed()
(note thatOnDeactivate()
is not called if your page is currently the active page)OnDeactivate()
(only called if your page is currently the active page)OnApply()
OnClosed()
So you should be able to override the
OnApply()
method and perform your saving in there.Just remember that only one instance of your UserControl is created, no matter how many times you open and close the Options dialog. To account for that,…