I have an application where you can open many different items (like in excel you can open many different tabs) If an item or “tab” is modified I want to detect the changes and allow the use to save or prompt if the user closes without saving. Maybe enable/disabling save button when a save is available/not available.
I am using c# WPF with MVVM pattern.
I have an application where you can open many different items (like in excel
Share
The common pattern for this problem is the ‘isDirty’ pattern. Basically you have a boolean flag ‘isDirty’ for all of your data pieces to mark whether or not they have been changed since the last save. You update this field when the data is modified or the document is saved.
Here is an example of a WPF ‘isDirty’ implementation: Almost-automatic INotifyPropertyChanged, automatic IsDirty, and automatic ChangeTracking