smeacham

TitleViewModel.cs

Jun 2nd, 2016
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 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.     class TitleViewModel : INotifyPropertyChanged
  13.     {
  14.         public event PropertyChangedEventHandler PropertyChanged;
  15.         String title;
  16.  
  17.         public string Title
  18.         {
  19.             set
  20.             {
  21.                 if (!value.Equals(title, StringComparison.Ordinal))
  22.                 {
  23.                     title = value;
  24.                     OnPropertyChanged("Title");
  25.                 }
  26.             }
  27.             get
  28.             {
  29.                 return title;
  30.             }
  31.         }
  32.  
  33.         void OnPropertyChanged([CallerMemberName] string propertyName = null)
  34.         {
  35.             var handler = PropertyChanged;
  36.             if (handler != null)
  37.             {
  38.                 handler(this, new PropertyChangedEventArgs(propertyName));
  39.             }
  40.         }
  41.     }
  42. }
Add Comment
Please, Sign In to add comment