Are all the properties you wish to watch for in the same class? If so, something like this will work:
- Have the class derive from INotifyPropertyChanged;
- Watch for property changes from the class and set an IsDirty flag when there are changes
- Set IsEnabled for the Save button based on the IsDirty flag
- When the Save command is executed, set IsDirty=false
Notifying Class Example
public class NotifyingClass : INotifyPropertyChanged
{
private string Property1Field;
public string Property1
{
get { return this.Property1Field; }
set { this.Property1Field = value; OnPropertyChanged("Property1"); }
}
private string Property2Field;
public string Property2
{
get { return this.Property2Field; }
set { this.Property2Field = value; OnPropertyChanged("Property2"); }
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
#endregion
}
Watching for Property Changes
public partial class MainWindow : Window
{
private bool isDirty;
NotifyingClass MyProperties = new NotifyingClass();
public MainWindow()
{
InitializeComponent();
this.MyProperties.PropertyChanged += (s, e) =>
{
this.isDirty = true;
};
}
}
How you set the disabled/enabled state depends on what type of button/command implementation you are doing. If you would like further help just let me know how you are doing it (event handler, RoutedCommand, RelayCommand, other) and I'll check it out.