Advertisement
Guest User

Untitled

a guest
Aug 12th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.35 KB | None | 0 0
  1. using System;
  2. using System.Windows;
  3. using System.Windows.Input;
  4. using MvvmFoundation.Wpf;
  5.  
  6. namespace MVVM_Test.ViewModel
  7. {
  8.     public class ViewModel : ObservableObject
  9.     {
  10.         private DateTime selectedDate;
  11.         public DateTime SelectedDate
  12.         {
  13.             get
  14.             {
  15.                 return selectedDate;
  16.             }
  17.             set
  18.             {
  19.                 selectedDate = value;
  20.                 RaisePropertyChanged("SelectedDate");
  21.             }
  22.         }
  23.  
  24.         public ViewModel()
  25.         {
  26.             SelectedDate = DateTime.Now;
  27.         }
  28.  
  29.         public ICommand PrevHistory_cmd
  30.         {
  31.             get { return new RelayCommand(PrevHistoryExecute, PrevHistoryCanExecute); }
  32.         }
  33.  
  34.         private void PrevHistoryExecute()
  35.         {
  36.             SelectedDate = SelectedDate - new TimeSpan(1, 0, 0, 0);
  37.         }
  38.  
  39.         private bool PrevHistoryCanExecute()
  40.         {
  41.             return true;
  42.         }
  43.  
  44.         public ICommand NextHistory_cmd
  45.         {
  46.             get { return new RelayCommand(NextHistoryExecute, NextHistoryCanExecute); }
  47.         }
  48.  
  49.         private void NextHistoryExecute()
  50.         {
  51.             SelectedDate = SelectedDate + new TimeSpan(1, 0, 0, 0);
  52.         }
  53.  
  54.         private bool NextHistoryCanExecute()
  55.         {
  56.             return true;
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement