title: How do I bind a SelectedDateChanged event from a DatePicker to a Command in my VM
body: <p>I have this wpf file with an empty codebehind file (And I would like to keep the codebehind empty if possible)</p>
  
  <p><a href="http://pastebin.com/x1CTZDFK" rel="nofollow">http://pastebin.com/x1CTZDFK</a></p>
  
  <p>And I then have this viewmodel file </p>
  
  <pre><code>using System;
  using System.Collections.ObjectModel;
  using System.Windows.Input;
  using MVVM_Test.Model;
  using MvvmFoundation.Wpf;
  
  namespace MVVM_Test.ViewModel
  {
      public class ViewModel : ObservableObject
      {
          private DateTime selectedDate;
          public DateTime SelectedDate
          {
              get
              {
                  return selectedDate;
              }
              set
              {
                  selectedDate = value;
                  RaisePropertyChanged("SelectedDate");
              }
          }
  
          private DateTime startDate;
          public DateTime StartDate
          {
              get { return startDate; }
              set
              {
                  startDate = value;
                  RaisePropertyChanged("StartDate");
              }
          }
  
          private DateTime endDate;
          public DateTime EndDate
          {
              get { return endDate; }
              set
              {
                  endDate = value;
                  RaisePropertyChanged("EndDate");
              }
          }
  
          public ObservableCollection&lt;Brick&gt; SavedBricks { get; set; }
  
          public ViewModel()
          {
              SelectedDate = DateTime.Now;
              StartDate = new DateTime(2011, 1, 1);
              EndDate = new DateTime(2011, 7, 31);
              SavedBricks = new ObservableCollection&lt;Brick&gt;();
              //Brick b1 = new Brick(DateTime.Now, 50,50,50,300);
              //SavedBricks.Add(b1);
          }
  
          public ICommand PrevHistory_cmd
          {
              get { return new RelayCommand(PrevHistoryExecute, PrevHistoryCanExecute); }
          }
  
          private void PrevHistoryExecute()
          {
              SelectedDate = SelectedDate - new TimeSpan(1, 0, 0, 0);
          }
  
          private bool PrevHistoryCanExecute()
          {
              if (StartDate &lt; SelectedDate)
                  return true;
              return false;
          }
  
          public ICommand NextHistory_cmd
          {
              get { return new RelayCommand(NextHistoryExecute, NextHistoryCanExecute); }
          }
  
          private void NextHistoryExecute()
          {
              SelectedDate = SelectedDate + new TimeSpan(1, 0, 0, 0);
          }
  
          private bool NextHistoryCanExecute()
          {
              if(EndDate &gt; SelectedDate)
                  return true;
              return false;
          }
  
          public ICommand StartStopSort_cmd
          {
              get { return new RelayCommand(NextHistoryExecute, NextHistoryCanExecute); }
          }
  
          private void StartStopSortExecute()
          {
  
          }
  
          private bool StartStopSortCanExecute()
          {
              return true;
          }
  
          public ICommand DateSelectionChanged_cmd
          {
              get { return new RelayCommand(NextHistoryExecute, NextHistoryCanExecute); }
          }
  
          private void DateSelectionChangedExecute()
          {
  
          }
  
          private bool DateSelectionChangedCanExecute()
          {
              return true;
          }
      }
  }
  </code></pre>
  
  <p>I then want the SelectedDateChanged event to execute my public ICommand DateSelectionChanged_cmd so that I can validate it in my view model. I tried getting the System.Windows.Interactivity to work but when I add it as a reference it wont compile and says it cant find the file, so now I wonder if there is any other way to do this, the way I wrote it in the xml file is just an example of how I would guess it would look (Which is the wrong way)</p>