public class SalesRow : INotifyPropertyChanged { #region Private Fields private event PropertyChangedEventHandler propertyChanged; private string label; private int[] values; #endregion #region Constructors public SalesRow() { this.label = ""; this.values = new int[4]; } public SalesRow(string label, int[] values) { if (values == null) { throw new ArgumentNullException(); } if (values.Length != 4) { throw new ArgumentException(); } this.label = label; this.values = values; } #endregion #region Public Events public virtual event PropertyChangedEventHandler PropertyChanged { add { this.propertyChanged += value; } remove { this.propertyChanged -= value; } } #endregion #region Private Methods protected virtual void OnPropertyChanged(string propertyName) { PropertyChangedEventHandler handler = this.propertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(propertyName)); } } #endregion #region Public Properties public virtual string Label { get { return this.label; } set { if (this.label != value) { this.label = value; this.OnPropertyChanged("Label"); } } } public virtual int Q1 { get { return this.values[0]; } set { if (this.values[0] != value) { this.values[0] = value; this.OnPropertyChanged("Q1"); this.OnPropertyChanged("Year"); } } } public virtual int Q2 { get { return this.values[1]; } set { if (this.values[1] != value) { this.values[1] = value; this.OnPropertyChanged("Q2"); this.OnPropertyChanged("Year"); } } } public virtual int Q3 { get { return this.values[2]; } set { if (this.values[2] != value) { this.values[2] = value; this.OnPropertyChanged("Q3"); this.OnPropertyChanged("Year"); } } } public virtual int Q4 { get { return this.values[3]; } set { if (this.values[3] != value) { this.values[3] = value; this.OnPropertyChanged("Q4"); this.OnPropertyChanged("Year"); } } } public virtual int Year { get { int sum = 0; foreach (int value in values) { sum += value; } return sum; } } #endregion }