What would be the cleanest way to have a Save state for an application so that whenever a property or content was updated the “Save” options would become enabled.
For example, there is a menu and toolbar “Save” buttons. When the WPF app first opens both buttons are disabled. When the user updates the properties or document, the buttons become enabled until a “Save” is done, at which point they go back to disabled.
Bind
IsEnabledto a ViewModel that exposes an “IsDirty” or “HasBeenModified” boolean property, or something of similar ilk. The ViewModel would watch for changes to the Model and set IsDirty to true if the Model is modified for any reason. When saved, the ViewModel can be told to set IsDirty to false, disabling the button.You are using the Model-View-ViewModel pattern, right? Here are a few links on the pattern to help you on your way, just in case:
http://en.wikipedia.org/wiki/Model_View_ViewModel
http://msdn.microsoft.com/en-us/magazine/dd419663.aspx
http://www.wintellect.com/CS/blogs/jlikness/archive/2010/04/14/model-view-viewmodel-mvvm-explained.aspx