Create a settings class that inherits from SettingsBase
Add a property backed by Set- and GetSetting
Subscribe to the settings class's PropertyChanged event
Add a button that sets the property to null when clicked
Note that setting the property to null effectively resets the setting (by forcing it to re-evaluate the default value function), but does not invoke PropertyChanged
This issue is particularly noticeable when attempting to reset a property that is bound to a UI element, as the UI doesn't know the property value changed and therefore won't update.
Acceptable solutions are:
Correcting the SetSetting method to invoke PropertyChanged even when a null value is passed
Add a ResetSetting/SetDefault method to explicitly set a property to its default
How to reproduce:
SettingsBase
Set-
andGetSetting
PropertyChanged
eventnull
when clickednull
effectively resets the setting (by forcing it to re-evaluate the default value function), but does not invokePropertyChanged
This issue is particularly noticeable when attempting to reset a property that is bound to a UI element, as the UI doesn't know the property value changed and therefore won't update.
Acceptable solutions are:
SetSetting
method to invokePropertyChanged
even when a null value is passedResetSetting
/SetDefault
method to explicitly set a property to its default