Guest User

Untitled

a guest
Jul 21st, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. public class Bar : INotifyPropertyChanged
  2. {
  3. public event PropertyChangedEventHandler PropertyChanged;
  4. private string foo;
  5. public string Foo
  6. {
  7. get { return this.foo; }
  8. set
  9. {
  10. if(value==this.foo)
  11. return;
  12. this.foo = value;
  13. this.OnPropertyChanged("Foo");
  14. }
  15. }
  16. private void OnPropertyChanged(string propertyName)
  17. {
  18. if(this.PropertyChanged!=null)
  19. this.PropertyChanged(this,new PropertyChangedEventArgs(propertyName));
  20. }
  21. }
  22.  
  23. // This is a simple customer class that
  24. // implements the IPropertyChange interface.
  25. public class DemoCustomer : INotifyPropertyChanged
  26. {
  27. // These fields hold the values for the public properties.
  28. private string customerNameValue = String.Empty;
  29.  
  30. public event PropertyChangedEventHandler PropertyChanged;
  31.  
  32. private void NotifyPropertyChanged(String info)
  33. {
  34. var listeners = PropertyChanged;
  35. if (listeners != null)
  36. {
  37. PropertyChanged(this, new PropertyChangedEventArgs(info));
  38. }
  39. }
  40.  
  41. public string CustomerName
  42. {
  43. get
  44. {
  45. return this.customerNameValue;
  46. }
  47.  
  48. set
  49. {
  50. if (value != this.customerNameValue)
  51. {
  52. this.customerNameValue = value;
  53. NotifyPropertyChanged("CustomerName");
  54. }
  55. }
  56. }
  57. }
Add Comment
Please, Sign In to add comment