title: C# Validate Date Picker in WPF using IDataErrorInfo & INotify
body: <p>I am trying to validate Date Picker using IDataErrorInfo</p>
  
  <p>I want to check if selected date is a week ahead also if selected date is in the past</p>
  
  <p>What I've done so far...</p>
  
  <pre><code>DateTime today = DateTime.Today;
                  DateTime seven = DateTime.Today.AddDays(+7);
                  DateTime dt = Convert.ToDateTime(DepartureDate);
  
                  if (columnName == "DepartureDate")
                  {
                      //range between today and seven days ahead +7
                      if (dt &gt;= today &amp;&amp; dt &lt;= seven)
                      {
                          result = valid;
                          return result;
                      }
                      //can't be in the past
                      if (dt.Date == today)
                      {
                          result = "Can't be in the past";
                          return result;
                      }
                      if (dt.Date == today.Date)
                      {
                          result = valid;
                          return result;
                      }
                  }
  </code></pre>
  
  <p>.</p>
  
  <pre><code>&lt;DatePicker Height="25" Validation.ErrorTemplate="{StaticResource eTemplate}" SelectedDate="{Binding StartDate}" HorizontalAlignment="Left" Margin="424,170,0,0" Name="DepartureDate" VerticalAlignment="Top" Width="119" FontSize="12"&gt;
              &lt;DatePicker.DisplayDate&gt;
                  &lt;Binding Path="DepartureDate" ValidatesOnDataErrors="True" UpdateSourceTrigger="PropertyChanged"/&gt;
              &lt;/DatePicker.DisplayDate&gt;
          &lt;/DatePicker&gt;
  </code></pre>