title: Overriding Calendar Style in DatePicker
body: <p>So I wrote this code a while ago and it used to work fine, but recently for whatever reason now it doesn't work at all.  Here's the xaml...</p>
  
  <pre><code>&lt;DatePicker SelectedDate="{Binding Criteria}" IsEnabled="{Binding IsEnabled}" Width="130" HorizontalAlignment="Right"&gt;
      &lt;DatePicker.CommandBindings&gt;
          &lt;CommandBinding Command="controls:DateCommands.SelectToday" CanExecute="CommandBinding_CanExecute" Executed="CommandBinding_Executed"/&gt;
      &lt;/DatePicker.CommandBindings&gt;
      &lt;DatePicker.CalendarStyle&gt;
          &lt;Style TargetType="{x:Type Calendar}"&gt;
              &lt;Setter Property="Template"&gt;
                  &lt;Setter.Value&gt;
                      &lt;ControlTemplate TargetType="{x:Type Calendar}"&gt;
                          &lt;TabControl&gt;
                              &lt;TabItem Header="Calender"&gt;
                                  &lt;CalendarItem Background="{TemplateBinding Control.Background}" BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="{TemplateBinding Control.BorderThickness}" Style="{TemplateBinding Calendar.CalendarItemStyle}" /&gt;
                              &lt;/TabItem&gt;
                              &lt;TabItem Header="Relative Time"&gt;
                                  &lt;Grid&gt;
                                      &lt;Grid.ColumnDefinitions&gt;
                                          &lt;ColumnDefinition/&gt;
                                          &lt;ColumnDefinition/&gt;
                                      &lt;/Grid.ColumnDefinitions&gt;
                                      &lt;Button Grid.Column="0" Command="controls:DateCommands.SelectToday" CommandParameter="Today" Content="Today" /&gt;
                                      &lt;Button Grid.Column="1" Command="controls:DateCommands.SelectToday" CommandParameter="Yesterday" Content="Yesterday" /&gt;
                                  &lt;/Grid&gt;
                              &lt;/TabItem&gt;
                          &lt;/TabControl&gt;
                      &lt;/ControlTemplate&gt;
                  &lt;/Setter.Value&gt;
              &lt;/Setter&gt;
          &lt;/Style&gt;
      &lt;/DatePicker.CalendarStyle&gt;
  &lt;/DatePicker&gt;
  </code></pre>
  
  <p>Basically I am overriding the calendar of the date picker and putting in a tab control that allows the user to select a relative time macro rather than an actual time (causing the generated query to always use that relative time).  This used to work fine, but now whenever I try to select from the calendar nothing happens and no values are ever populated in the box, or in the backing property.</p>
  
  <p>I took the code out and dumped it into a new project to experiment and couldn't get this simple case to even work...</p>
  
  <pre><code>&lt;DatePicker Width="130" HorizontalAlignment="Right"&gt;
      &lt;DatePicker.CalendarStyle&gt;
          &lt;Style TargetType="{x:Type Calendar}"&gt;
              &lt;Setter Property="Template"&gt;
                  &lt;Setter.Value&gt;
                      &lt;ControlTemplate TargetType="{x:Type Calendar}"&gt;
                          &lt;CalendarItem Background="{TemplateBinding Control.Background}" BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="{TemplateBinding Control.BorderThickness}" Style="{TemplateBinding Calendar.CalendarItemStyle}" /&gt;
                      &lt;/ControlTemplate&gt;
                  &lt;/Setter.Value&gt;
              &lt;/Setter&gt;
          &lt;/Style&gt;
      &lt;/DatePicker.CalendarStyle&gt;
  &lt;/DatePicker&gt;
  </code></pre>
  
  <p>This code does the same thing, whenever you try to pick a date from the calendar, nothing happens.  This used to work, and to my knowledge nothing has changed, anybody have any insight on what's going on, or perhaps a better implementation of what I am trying to do?</p>