Advertisement
Guest User

Untitled

a guest
Nov 29th, 2014
588
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.40 KB | None | 0 0
  1. using TestMVVM.Notifications;
  2.  
  3. namespace TestMVVM.ViewModels
  4. {
  5.     class JournalViewModel : PropertyChangedNotification
  6.     {
  7.         #region Fields for binding
  8.         public CommonViewModel Common
  9.         {
  10.             get { return GetValue(() => Common); }
  11.             set { SetValue(() => Common, value); }
  12.         }
  13.  
  14.         public ObservableCollection<BoreViewModel> Bores
  15.         {
  16.             get { return GetValue(() => Bores); }
  17.             set { SetValue(() => Bores, value); }
  18.         }
  19.  
  20.         public BoreViewModel ActiveBore
  21.         {
  22.             get { return GetValue(() => ActiveBore); }
  23.             set { SetValue(() => ActiveBore, value); }
  24.         }
  25.  
  26.         public bool IsInfoActive
  27.         {
  28.             get { return GetValue(() => IsInfoActive); }
  29.             set { SetValue(() => IsInfoActive, value); }
  30.         }
  31.         #endregion
  32.  
  33.         public JournalViewModel(Journal journal)
  34.         {
  35.             Common = new CommonViewModel(journal.Common);
  36.             Bores = new ObservableCollection<BoreViewModel>();
  37.             var editCommand = new RelayCommand(o => ActivateBore((BoreViewModel)o));
  38.             foreach (var bore in journal.Bores)
  39.                 Bores.Add(new BoreViewModel(bore, editCommand));
  40.         }
  41.  
  42.         public void ActivateBore(BoreViewModel vm)
  43.         {
  44.             ActiveBore = vm;
  45.             IsInfoActive = true;
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement