title: TwoWay binding not working with datepicker MVVM
body: <p>I've finally managed to get started with MVVM and implementing INotifyPropertyChanged and I am facing the following problem: Even though I pass the month from my datepicker as a parameter to my query, the result of my query doesn't change if I choose a different month. </p>
  
  <p>I was hoping INotifyPropertyChanged would take care of that. How do I make sure that my Efficiency changes when picking a different month from the datepicker?</p>
  
  <p>Thank you</p>
  
  <p><strong>ViewModel</strong></p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using Location.Model;
  using System.Windows.Controls;
  
  namespace Location.ViewModel
  {
      public class LocationViewModel: INotifyPropertyChanged
      {
  
  
          public LocationViewModel()
          {
              var month = 0;
              int.TryParse(MDate.ToString("MM"), out month);
              var db = new DailyEntities();
              Efficiency = Convert.ToDecimal(db.LocationKPI.Where(a =&gt; a.sMonth == month).Select(a =&gt; a.Efficiency).FirstOrDefault());
          }
  
          private DateTime _mDate = DateTime.Now;
  
          public DateTime MDate
          {
              get { return _mDate; }
              set { _mDate = value; OnPropertyChanged("MDate"); }
          }
  
          decimal efficiency;
  
          public decimal Efficiency
          {
              get { return efficiency; }
              set
              {
                  efficiency = value;
                  OnPropertyChanged("Efficiency");
              }
          }
  
  
          public event PropertyChangedEventHandler PropertyChanged;
  
          protected virtual void OnPropertyChanged(string propertyName = null)
          {
              if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
          }
      }
  }
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>public partial class MainWindow : Window
  {
      public MainWindow()
      {
          InitializeComponent();
          DataContext = new LocationViewModel();
      }
  }
  </code></pre>
  
  <p><strong>XAML</strong></p>
  
  <pre><code>&lt;DatePicker x:Name="vDatePick" SelectedDateChanged="vDatePick_SelectedDateChanged" SelectedDate="{Binding MDate, Mode=TwoWay}" Text="Pick date"/&gt;
  </code></pre>