The program has a button by pressing which the user can reset the values ​​of all settings to the default value. Settings are stored in the SettingsVM object.

There are a lot of settings and in order not to reset each property individually, I simply create a new object.

 public class MainVM : BaseVM { public SearchVM SearchVM { get; set; } public static SettingsVM SettingsVM { get; set; } public MainVM() { SearchVM = new SearchVM(); SettingsVM = new SettingsVM(); ResetSettingsCommand = new RelayCommand(ResetSettings); } public ICommand ResetSettingsCommand { get; } private void ResetSettings() { SettingsVM = new SettingsVM(); OnPropertyChanged(String.Empty); } } 

The problem is that after practicing the ResetSettings method ResetSettings interface does not change, but remains tied to the "old" object.

How to correct this behavior?

    1 answer 1

    Your SettingsVM property, containing settings, is static. For him, the INotifyPropertyChanged interface INotifyPropertyChanged not work. Make the property non-static.

    You will need to change the binding code in XAML, for non-static properties it is different (simpler).

    • All VMs are inherited from BaseVM , which implements INotifyPropertyChanged . - trydex
    • one
      @maxwell: Changed the answer - VladD
    • Thank. Without static works. - trydex
    • one
      @maxwell: Please! Glad that helped. - VladD