Advertisement
smeacham

ItemViewModel.cs

Jun 2nd, 2016
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.18 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 ItemViewModel : INotifyPropertyChanged
  13.     {
  14.         public event PropertyChangedEventHandler PropertyChanged;
  15.  
  16.         Item item;
  17.  
  18.         public ItemViewModel()
  19.         {
  20.             item = new Item();
  21.         }
  22.  
  23.         // Only Title is exposed...Description is not used by this view
  24.         public string Title
  25.         {
  26.             set
  27.             {
  28.                 if (!value.Equals(item.Title, StringComparison.Ordinal))
  29.                 {
  30.                     item.Title = value;
  31.                     OnPropertyChanged("Title");
  32.                 }
  33.             }
  34.             get
  35.             {
  36.                 return item.Title;
  37.             }
  38.         }
  39.  
  40.         void OnPropertyChanged([CallerMemberName] string propertyName = null)
  41.         {
  42.             var handler = PropertyChanged;
  43.             if (handler != null)
  44.             {
  45.                 handler(this, new PropertyChangedEventArgs(propertyName));
  46.             }
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement