Advertisement
smeacham

ItemBindable.cs

Jun 2nd, 2016
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.39 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 ScratchVS
  11. {
  12.     class ItemBindable
  13.     {
  14.         public event PropertyChangedEventHandler PropertyChanged;
  15.  
  16.         string title;
  17.         string description;
  18.  
  19.         public string Title
  20.         {
  21.             set
  22.             {
  23.                 if (!value.Equals(title, StringComparison.Ordinal))
  24.                 {
  25.                     title = value;
  26.                     OnPropertyChanged("Title");
  27.                 }
  28.             }
  29.             get
  30.             {
  31.                 return title;
  32.             }
  33.         }
  34.  
  35.         public string Description
  36.         {
  37.             set
  38.             {
  39.                 if (!value.Equals(description, StringComparison.Ordinal))
  40.                 {
  41.                     title = value;
  42.                     OnPropertyChanged("Title");
  43.                 }
  44.             }
  45.             get
  46.             {
  47.                 return description;
  48.             }
  49.         }
  50.  
  51.         void OnPropertyChanged([CallerMemberName] string propertyName = null)
  52.         {
  53.             var handler = PropertyChanged;
  54.             if (handler != null)
  55.             {
  56.                 handler(this, new PropertyChangedEventArgs(propertyName));
  57.             }
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement