using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ComponentModel; namespace ObjectBinding { public class Product : INotifyPropertyChanged { // Declare the PropertyChanged event. public event PropertyChangedEventHandler PropertyChanged; // OnPropertyChanged() method raises the event. protected void OnPropertyChanged(string propertyName) { if (this.PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } private int productID; public int ProductID { get { return productID; } set { productID = value; OnPropertyChanged("ProductID"); } } private string productName; public string ProductName { get { return productName; } set { productName = value; OnPropertyChanged("ProductName"); } } private int categoryID; public int CategoryID { get { return categoryID; } set { categoryID = value; OnPropertyChanged("CategoryID"); } } private decimal unitPrice; public decimal UnitPrice { get { return unitPrice; } set { unitPrice = value; OnPropertyChanged("UnitPrice"); } } private short unitsInStock; public short UnitsInStock { get { return unitsInStock; } set { unitsInStock = value; OnPropertyChanged("UnitsInStock"); } } public override string ToString() { return string.Format("[{0}]: {1}, Category {2}, ${3}, {4} in stock.", ProductID, ProductName, CategoryID, UnitPrice, UnitsInStock); } } }