Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Bar : INotifyPropertyChanged
- {
- public event PropertyChangedEventHandler PropertyChanged;
- private string foo;
- public string Foo
- {
- get { return this.foo; }
- set
- {
- if(value==this.foo)
- return;
- this.foo = value;
- this.OnPropertyChanged("Foo");
- }
- }
- private void OnPropertyChanged(string propertyName)
- {
- if(this.PropertyChanged!=null)
- this.PropertyChanged(this,new PropertyChangedEventArgs(propertyName));
- }
- }
- // This is a simple customer class that
- // implements the IPropertyChange interface.
- public class DemoCustomer : INotifyPropertyChanged
- {
- // These fields hold the values for the public properties.
- private string customerNameValue = String.Empty;
- public event PropertyChangedEventHandler PropertyChanged;
- private void NotifyPropertyChanged(String info)
- {
- var listeners = PropertyChanged;
- if (listeners != null)
- {
- PropertyChanged(this, new PropertyChangedEventArgs(info));
- }
- }
- public string CustomerName
- {
- get
- {
- return this.customerNameValue;
- }
- set
- {
- if (value != this.customerNameValue)
- {
- this.customerNameValue = value;
- NotifyPropertyChanged("CustomerName");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment