smeacham

BindableBase.cs

Jun 2nd, 2016
430
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.85 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. using System.ComponentModel;
  8. using System.Runtime.CompilerServices;
  9.  
  10. namespace NonTrivialDataBindingDemoVS
  11. {
  12.     /*
  13.      * An abstract class that implements INotifyPropertyChanged.
  14.      * Subclass BindableBase in your models or view models to make
  15.      * them ready for nontrivial binding.
  16.      */
  17.     public abstract class BindableBase : INotifyPropertyChanged
  18.     {
  19.         public event PropertyChangedEventHandler PropertyChanged;
  20.        
  21.         void OnPropertyChanged([CallerMemberName] string propertyName = null)
  22.         {
  23.             var handler = PropertyChanged;
  24.             if (handler != null)
  25.             {
  26.                 handler(this, new PropertyChangedEventArgs(propertyName));
  27.             }
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment