title: WPF Toolkit: Bug in Control Template?
body: <p>Here's one for all you XAML wizards: The WPF Toolkit <code>Calendar</code> control (June 2009) appears to have a bug. The bug only crops up when you modify the <code>ControlTemplate</code> for the calendar, specifically, the <code>PART_CalendarItem</code>.</p>
  <p>At the end of this message, I have included the XAML for a (Blend 3.0) window that declares a <code>Calendar</code> and assigns it a <code>ControlTemplate</code>. The control template is an unmodified copy of the Calendar control template, which I got by editing a copy of the control template (in Blend) for the Calendar control and the PART_CalendarItem control.</p>
  <p>In line 78 of the XAML (Marked with a comment &quot;EXCEPTION&quot; below), the <code>VisualStateManager</code> assigns a <code>TextColor</code> to a mouse-over on the <code>Month</code> header of the control. However, in the control template the text color is assigned to the <code>Grid</code> that holds the <code>Month</code> button, rather than the month button itself. That causes an exception in both VS2008 and Blend 3.0 when a calendar is assigned the unmodified control template, as in the XAML below.</p>
  <p>I can't quite figure out how to modify the control template to eliminate the bug, short of removing the mouse-over highlighting. I'd like to keep it, but I don't see what the <code>TextColor</code> property should target. Any suggestions? Thanks for your help!</p>
  <br/>
  <br/>
  <br/>
  <hr />
  <p><b>XAML Markup</b></p>
  <hr />
  <pre><code>&lt;Window
      xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
      xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
      xmlns:Custom=&quot;http://schemas.microsoft.com/wpf/2008/toolkit&quot;
      x:Class=&quot;WpfApplication1.MainWindow&quot;
      x:Name=&quot;Window&quot;
      Title=&quot;MainWindow&quot;
      Width=&quot;640&quot; Height=&quot;480&quot;&gt;
      &lt;Window.Resources&gt;
          &lt;Style x:Key=&quot;CalendarStyle1&quot; TargetType=&quot;{x:Type Custom:Calendar}&quot;&gt;
              &lt;Setter Property=&quot;Foreground&quot; Value=&quot;#FF333333&quot;/&gt;
              &lt;Setter Property=&quot;Background&quot;&gt;
                  &lt;Setter.Value&gt;
                      &lt;LinearGradientBrush EndPoint=&quot;0.5,1&quot; StartPoint=&quot;0.5,0&quot;&gt;
                          &lt;GradientStop Color=&quot;#FFE4EAF0&quot; Offset=&quot;0&quot;/&gt;
                          &lt;GradientStop Color=&quot;#FFECF0F4&quot; Offset=&quot;0.16&quot;/&gt;
                          &lt;GradientStop Color=&quot;#FFFCFCFD&quot; Offset=&quot;0.16&quot;/&gt;
                          &lt;GradientStop Color=&quot;White&quot; Offset=&quot;1&quot;/&gt;
                      &lt;/LinearGradientBrush&gt;
                  &lt;/Setter.Value&gt;
              &lt;/Setter&gt;
              &lt;Setter Property=&quot;BorderBrush&quot;&gt;
                  &lt;Setter.Value&gt;
                      &lt;LinearGradientBrush EndPoint=&quot;0.5,1&quot; StartPoint=&quot;0.5,0&quot;&gt;
                          &lt;GradientStop Color=&quot;#FFA3AEB9&quot; Offset=&quot;0&quot;/&gt;
                          &lt;GradientStop Color=&quot;#FF8399A9&quot; Offset=&quot;0.375&quot;/&gt;
                          &lt;GradientStop Color=&quot;#FF718597&quot; Offset=&quot;0.375&quot;/&gt;
                          &lt;GradientStop Color=&quot;#FF617584&quot; Offset=&quot;1&quot;/&gt;
                      &lt;/LinearGradientBrush&gt;
                  &lt;/Setter.Value&gt;
              &lt;/Setter&gt;
              &lt;Setter Property=&quot;BorderThickness&quot; Value=&quot;1&quot;/&gt;
              &lt;Setter Property=&quot;Template&quot;&gt;
                  &lt;Setter.Value&gt;
                      &lt;ControlTemplate TargetType=&quot;{x:Type Custom:Calendar}&quot;&gt;
                          &lt;StackPanel x:Name=&quot;PART_Root&quot; HorizontalAlignment=&quot;Center&quot;&gt;
                              &lt;Custom:CalendarItem x:Name=&quot;PART_CalendarItem&quot; Style=&quot;{DynamicResource CalendarItemStyle1}&quot; Background=&quot;{TemplateBinding Background}&quot; BorderBrush=&quot;{TemplateBinding BorderBrush}&quot; BorderThickness=&quot;{TemplateBinding BorderThickness}&quot;/&gt;
                          &lt;/StackPanel&gt;
                      &lt;/ControlTemplate&gt;
                  &lt;/Setter.Value&gt;
              &lt;/Setter&gt;
          &lt;/Style&gt;
          &lt;Style x:Key=&quot;CalendarItemStyle1&quot; TargetType=&quot;{x:Type Custom:CalendarItem}&quot;&gt;
              &lt;Setter Property=&quot;Margin&quot; Value=&quot;0,3&quot;/&gt;
              &lt;Setter Property=&quot;Template&quot;&gt;
                  &lt;Setter.Value&gt;
                      &lt;ControlTemplate TargetType=&quot;{x:Type Custom:CalendarItem}&quot;&gt;
                          &lt;ControlTemplate.Resources&gt;
                              &lt;DataTemplate x:Key=&quot;DayTitleTemplate&quot;&gt;
                                  &lt;TextBlock HorizontalAlignment=&quot;Center&quot; Margin=&quot;0,6&quot; VerticalAlignment=&quot;Center&quot; FontFamily=&quot;Verdana&quot; FontSize=&quot;9.5&quot; FontWeight=&quot;Bold&quot; Foreground=&quot;#FF333333&quot; Text=&quot;{Binding}&quot;/&gt;
                              &lt;/DataTemplate&gt;
                          &lt;/ControlTemplate.Resources&gt;
                          &lt;Grid x:Name=&quot;PART_Root&quot;&gt;
                              &lt;Grid.Resources&gt;
                                  &lt;SolidColorBrush x:Key=&quot;DisabledColor&quot; Color=&quot;#A5FFFFFF&quot;/&gt;
                              &lt;/Grid.Resources&gt;
                              &lt;VisualStateManager.VisualStateGroups&gt;
                                  &lt;VisualStateGroup x:Name=&quot;CommonStates&quot;&gt;
                                      &lt;VisualState x:Name=&quot;Normal&quot;/&gt;
                                      &lt;VisualState x:Name=&quot;Disabled&quot;&gt;
                                          &lt;Storyboard&gt;
                                              &lt;DoubleAnimation Duration=&quot;00:00:00&quot; Storyboard.TargetName=&quot;PART_DisabledVisual&quot; Storyboard.TargetProperty=&quot;Opacity&quot; To=&quot;1&quot;/&gt;
                                          &lt;/Storyboard&gt;
                                      &lt;/VisualState&gt;
                                  &lt;/VisualStateGroup&gt;
                              &lt;/VisualStateManager.VisualStateGroups&gt;
                              &lt;Border Background=&quot;{TemplateBinding Background}&quot; BorderBrush=&quot;{TemplateBinding BorderBrush}&quot; BorderThickness=&quot;{TemplateBinding BorderThickness}&quot; CornerRadius=&quot;1&quot;&gt;
                                  &lt;Border BorderBrush=&quot;White&quot; BorderThickness=&quot;2&quot; CornerRadius=&quot;1&quot;&gt;
                                      &lt;Grid&gt;
                                          &lt;Grid.Resources&gt;
                                              &lt;ControlTemplate x:Key=&quot;HeaderButtonTemplate&quot; TargetType=&quot;{x:Type Button}&quot;&gt;
                                                  &lt;Grid Cursor=&quot;Hand&quot;&gt;
                                                      &lt;VisualStateManager.VisualStateGroups&gt;
                                                          &lt;VisualStateGroup x:Name=&quot;CommonStates&quot;&gt;
                                                              &lt;VisualState x:Name=&quot;Normal&quot;/&gt;
                                                              &lt;VisualState x:Name=&quot;MouseOver&quot;&gt;
                                                                  &lt;Storyboard&gt;
                                                                      &lt;ColorAnimation Duration=&quot;00:00:00&quot; Storyboard.TargetName=&quot;TextColor&quot; Storyboard.TargetProperty=&quot;Color&quot; To=&quot;#FF73A9D8&quot;/&gt; &lt;!-- EXCEPTION --&gt;
                                                                  &lt;/Storyboard&gt;
                                                              &lt;/VisualState&gt;
                                                              &lt;VisualState x:Name=&quot;Disabled&quot;&gt;
                                                                  &lt;Storyboard&gt;
                                                                      &lt;DoubleAnimation Duration=&quot;00:00:00&quot; Storyboard.TargetName=&quot;buttonContent&quot; Storyboard.TargetProperty=&quot;Opacity&quot; To=&quot;0.5&quot;/&gt;
                                                                  &lt;/Storyboard&gt;
                                                              &lt;/VisualState&gt;
                                                          &lt;/VisualStateGroup&gt;
                                                      &lt;/VisualStateManager.VisualStateGroups&gt;
                                                      &lt;ContentPresenter x:Name=&quot;buttonContent&quot; HorizontalAlignment=&quot;{TemplateBinding HorizontalContentAlignment}&quot; Margin=&quot;1,4,1,9&quot; VerticalAlignment=&quot;{TemplateBinding VerticalContentAlignment}&quot; TextElement.Foreground=&quot;#FF333333&quot; Content=&quot;{TemplateBinding Content}&quot; ContentTemplate=&quot;{TemplateBinding ContentTemplate}&quot;/&gt;
                                                  &lt;/Grid&gt;
                                              &lt;/ControlTemplate&gt;
                                              &lt;ControlTemplate x:Key=&quot;NextButtonTemplate&quot; TargetType=&quot;{x:Type Button}&quot;&gt;
                                                  &lt;Grid Cursor=&quot;Hand&quot;&gt;
                                                      &lt;VisualStateManager.VisualStateGroups&gt;
                                                          &lt;VisualStateGroup x:Name=&quot;CommonStates&quot;&gt;
                                                              &lt;VisualState x:Name=&quot;Normal&quot;/&gt;
                                                              &lt;VisualState x:Name=&quot;MouseOver&quot;&gt;
                                                                  &lt;Storyboard&gt;
                                                                      &lt;ColorAnimation Duration=&quot;00:00:00&quot; Storyboard.TargetName=&quot;TextColor&quot; Storyboard.TargetProperty=&quot;Color&quot; To=&quot;#FF73A9D8&quot;/&gt;
                                                                  &lt;/Storyboard&gt;
                                                              &lt;/VisualState&gt;
                                                              &lt;VisualState x:Name=&quot;Disabled&quot;&gt;
                                                                  &lt;Storyboard&gt;
                                                                      &lt;DoubleAnimation Duration=&quot;00:00:00&quot; Storyboard.TargetName=&quot;TextColor&quot; Storyboard.TargetProperty=&quot;Opacity&quot; To=&quot;0.5&quot;/&gt;
                                                                  &lt;/Storyboard&gt;
                                                              &lt;/VisualState&gt;
                                                          &lt;/VisualStateGroup&gt;
                                                      &lt;/VisualStateManager.VisualStateGroups&gt;
                                                      &lt;Rectangle Fill=&quot;#11E5EBF1&quot; Stretch=&quot;Fill&quot; Opacity=&quot;1&quot;/&gt;
                                                      &lt;Grid&gt;
                                                          &lt;Path Fill=&quot;#FF333333&quot; Stretch=&quot;Fill&quot; HorizontalAlignment=&quot;Right&quot; Margin=&quot;0,-6,14,0&quot; VerticalAlignment=&quot;Center&quot; Width=&quot;6&quot; Height=&quot;10&quot; Data=&quot;M282.875,231.875L282.875,240.375 288.625,236z&quot;/&gt;
                                                      &lt;/Grid&gt;
                                                  &lt;/Grid&gt;
                                              &lt;/ControlTemplate&gt;
                                              &lt;ControlTemplate x:Key=&quot;PreviousButtonTemplate&quot; TargetType=&quot;{x:Type Button}&quot;&gt;
                                                  &lt;Grid Cursor=&quot;Hand&quot;&gt;
                                                      &lt;VisualStateManager.VisualStateGroups&gt;
                                                          &lt;VisualStateGroup x:Name=&quot;CommonStates&quot;&gt;
                                                              &lt;VisualState x:Name=&quot;Normal&quot;/&gt;
                                                              &lt;VisualState x:Name=&quot;MouseOver&quot;&gt;
                                                                  &lt;Storyboard&gt;
                                                                      &lt;ColorAnimation Duration=&quot;00:00:00&quot; Storyboard.TargetName=&quot;TextColor&quot; Storyboard.TargetProperty=&quot;Color&quot; To=&quot;#FF73A9D8&quot;/&gt;
                                                                  &lt;/Storyboard&gt;
                                                              &lt;/VisualState&gt;
                                                              &lt;VisualState x:Name=&quot;Disabled&quot;&gt;
                                                                  &lt;Storyboard&gt;
                                                                      &lt;DoubleAnimation Duration=&quot;00:00:00&quot; Storyboard.TargetName=&quot;TextColor&quot; Storyboard.TargetProperty=&quot;Opacity&quot; To=&quot;0.5&quot;/&gt;
                                                                  &lt;/Storyboard&gt;
                                                              &lt;/VisualState&gt;
                                                          &lt;/VisualStateGroup&gt;
                                                      &lt;/VisualStateManager.VisualStateGroups&gt;
                                                      &lt;Rectangle Fill=&quot;#11E5EBF1&quot; Stretch=&quot;Fill&quot; Opacity=&quot;1&quot;/&gt;
                                                      &lt;Grid&gt;
                                                          &lt;Path Fill=&quot;#FF333333&quot; Stretch=&quot;Fill&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;14,-6,0,0&quot; VerticalAlignment=&quot;Center&quot; Width=&quot;6&quot; Height=&quot;10&quot; Data=&quot;M288.75,232.25L288.75,240.625 283,236.625z&quot;/&gt;
                                                      &lt;/Grid&gt;
                                                  &lt;/Grid&gt;
                                              &lt;/ControlTemplate&gt;
                                          &lt;/Grid.Resources&gt;
                                          &lt;Grid.ColumnDefinitions&gt;
                                              &lt;ColumnDefinition Width=&quot;Auto&quot;/&gt;
                                              &lt;ColumnDefinition Width=&quot;Auto&quot;/&gt;
                                              &lt;ColumnDefinition Width=&quot;Auto&quot;/&gt;
                                          &lt;/Grid.ColumnDefinitions&gt;
                                          &lt;Grid.RowDefinitions&gt;
                                              &lt;RowDefinition Height=&quot;Auto&quot;/&gt;
                                              &lt;RowDefinition Height=&quot;*&quot;/&gt;
                                          &lt;/Grid.RowDefinitions&gt;
                                          &lt;Button x:Name=&quot;PART_PreviousButton&quot; HorizontalAlignment=&quot;Left&quot; Width=&quot;28&quot; Height=&quot;20&quot; Focusable=&quot;False&quot; Grid.Column=&quot;0&quot; Grid.Row=&quot;0&quot;&gt;
                                              &lt;Button.Template&gt;
                                                  &lt;ControlTemplate TargetType=&quot;{x:Type Button}&quot;&gt;
                                                      &lt;Grid Cursor=&quot;Hand&quot;&gt;
                                                          &lt;VisualStateManager.VisualStateGroups&gt;
                                                              &lt;VisualStateGroup x:Name=&quot;CommonStates&quot;&gt;
                                                                  &lt;VisualState x:Name=&quot;Normal&quot;/&gt;
                                                                  &lt;VisualState x:Name=&quot;MouseOver&quot;&gt;
                                                                      &lt;Storyboard&gt;
                                                                          &lt;ColorAnimation Duration=&quot;00:00:00&quot; Storyboard.TargetName=&quot;TextColor&quot; Storyboard.TargetProperty=&quot;Color&quot; To=&quot;#FF73A9D8&quot;/&gt;
                                                                      &lt;/Storyboard&gt;
                                                                  &lt;/VisualState&gt;
                                                                  &lt;VisualState x:Name=&quot;Disabled&quot;&gt;
                                                                      &lt;Storyboard&gt;
                                                                          &lt;DoubleAnimation Duration=&quot;00:00:00&quot; Storyboard.TargetName=&quot;TextColor&quot; Storyboard.TargetProperty=&quot;Opacity&quot; To=&quot;0.5&quot;/&gt;
                                                                      &lt;/Storyboard&gt;
                                                                  &lt;/VisualState&gt;
                                                              &lt;/VisualStateGroup&gt;
                                                          &lt;/VisualStateManager.VisualStateGroups&gt;
                                                          &lt;Rectangle Fill=&quot;#11E5EBF1&quot; Stretch=&quot;Fill&quot; Opacity=&quot;1&quot;/&gt;
                                                          &lt;Grid&gt;
                                                              &lt;Path Fill=&quot;#FF333333&quot; Stretch=&quot;Fill&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;14,-6,0,0&quot; VerticalAlignment=&quot;Center&quot; Width=&quot;6&quot; Height=&quot;10&quot; Data=&quot;M288.75,232.25L288.75,240.625 283,236.625z&quot;/&gt;
                                                          &lt;/Grid&gt;
                                                      &lt;/Grid&gt;
                                                  &lt;/ControlTemplate&gt;
                                              &lt;/Button.Template&gt;
                                          &lt;/Button&gt;
                                          &lt;Button x:Name=&quot;PART_HeaderButton&quot; HorizontalAlignment=&quot;Center&quot; VerticalAlignment=&quot;Center&quot; FontSize=&quot;10.5&quot; FontWeight=&quot;Bold&quot; Focusable=&quot;False&quot; Grid.Column=&quot;1&quot; Grid.Row=&quot;0&quot; Template=&quot;{DynamicResource ButtonControlTemplate1}&quot;/&gt;
                                          &lt;Button x:Name=&quot;PART_NextButton&quot; HorizontalAlignment=&quot;Right&quot; Width=&quot;28&quot; Height=&quot;20&quot; Focusable=&quot;False&quot; Grid.Column=&quot;2&quot; Grid.Row=&quot;0&quot;&gt;
                                              &lt;Button.Template&gt;
                                                  &lt;ControlTemplate TargetType=&quot;{x:Type Button}&quot;&gt;
                                                      &lt;Grid Cursor=&quot;Hand&quot;&gt;
                                                          &lt;VisualStateManager.VisualStateGroups&gt;
                                                              &lt;VisualStateGroup x:Name=&quot;CommonStates&quot;&gt;
                                                                  &lt;VisualState x:Name=&quot;Normal&quot;/&gt;
                                                                  &lt;VisualState x:Name=&quot;MouseOver&quot;&gt;
                                                                      &lt;Storyboard&gt;
                                                                          &lt;ColorAnimation Duration=&quot;00:00:00&quot; Storyboard.TargetName=&quot;TextColor&quot; Storyboard.TargetProperty=&quot;Color&quot; To=&quot;#FF73A9D8&quot;/&gt;
                                                                      &lt;/Storyboard&gt;
                                                                  &lt;/VisualState&gt;
                                                                  &lt;VisualState x:Name=&quot;Disabled&quot;&gt;
                                                                      &lt;Storyboard&gt;
                                                                          &lt;DoubleAnimation Duration=&quot;00:00:00&quot; Storyboard.TargetName=&quot;TextColor&quot; Storyboard.TargetProperty=&quot;Opacity&quot; To=&quot;0.5&quot;/&gt;
                                                                      &lt;/Storyboard&gt;
                                                                  &lt;/VisualState&gt;
                                                              &lt;/VisualStateGroup&gt;
                                                          &lt;/VisualStateManager.VisualStateGroups&gt;
                                                          &lt;Rectangle Fill=&quot;#11E5EBF1&quot; Stretch=&quot;Fill&quot; Opacity=&quot;1&quot;/&gt;
                                                          &lt;Grid&gt;
                                                              &lt;Path Fill=&quot;#FF333333&quot; Stretch=&quot;Fill&quot; HorizontalAlignment=&quot;Right&quot; Margin=&quot;0,-6,14,0&quot; VerticalAlignment=&quot;Center&quot; Width=&quot;6&quot; Height=&quot;10&quot; Data=&quot;M282.875,231.875L282.875,240.375 288.625,236z&quot;/&gt;
                                                          &lt;/Grid&gt;
                                                      &lt;/Grid&gt;
                                                  &lt;/ControlTemplate&gt;
                                              &lt;/Button.Template&gt;
                                          &lt;/Button&gt;
                                          &lt;Grid x:Name=&quot;PART_MonthView&quot; Margin=&quot;6,-1,6,6&quot; Visibility=&quot;Visible&quot; Grid.ColumnSpan=&quot;3&quot; Grid.Row=&quot;1&quot;&gt;
                                              &lt;Grid.ColumnDefinitions&gt;
                                                  &lt;ColumnDefinition Width=&quot;Auto&quot;/&gt;
                                                  &lt;ColumnDefinition Width=&quot;Auto&quot;/&gt;
                                                  &lt;ColumnDefinition Width=&quot;Auto&quot;/&gt;
                                                  &lt;ColumnDefinition Width=&quot;Auto&quot;/&gt;
                                                  &lt;ColumnDefinition Width=&quot;Auto&quot;/&gt;
                                                  &lt;ColumnDefinition Width=&quot;Auto&quot;/&gt;
                                                  &lt;ColumnDefinition Width=&quot;Auto&quot;/&gt;
                                              &lt;/Grid.ColumnDefinitions&gt;
                                              &lt;Grid.RowDefinitions&gt;
                                                  &lt;RowDefinition Height=&quot;Auto&quot;/&gt;
                                                  &lt;RowDefinition Height=&quot;Auto&quot;/&gt;
                                                  &lt;RowDefinition Height=&quot;Auto&quot;/&gt;
                                                  &lt;RowDefinition Height=&quot;Auto&quot;/&gt;
                                                  &lt;RowDefinition Height=&quot;Auto&quot;/&gt;
                                                  &lt;RowDefinition Height=&quot;Auto&quot;/&gt;
                                                  &lt;RowDefinition Height=&quot;Auto&quot;/&gt;
                                              &lt;/Grid.RowDefinitions&gt;
                                          &lt;/Grid&gt;
                                          &lt;Grid x:Name=&quot;PART_YearView&quot; Margin=&quot;6,-3,7,6&quot; Visibility=&quot;Hidden&quot; Grid.ColumnSpan=&quot;3&quot; Grid.Row=&quot;1&quot;&gt;
                                              &lt;Grid.ColumnDefinitions&gt;
                                                  &lt;ColumnDefinition Width=&quot;Auto&quot;/&gt;
                                                  &lt;ColumnDefinition Width=&quot;Auto&quot;/&gt;
                                                  &lt;ColumnDefinition Width=&quot;Auto&quot;/&gt;
                                                  &lt;ColumnDefinition Width=&quot;Auto&quot;/&gt;
                                              &lt;/Grid.ColumnDefinitions&gt;
                                              &lt;Grid.RowDefinitions&gt;
                                                  &lt;RowDefinition Height=&quot;Auto&quot;/&gt;
                                                  &lt;RowDefinition Height=&quot;Auto&quot;/&gt;
                                                  &lt;RowDefinition Height=&quot;Auto&quot;/&gt;
                                              &lt;/Grid.RowDefinitions&gt;
                                          &lt;/Grid&gt;
                                      &lt;/Grid&gt;
                                  &lt;/Border&gt;
                              &lt;/Border&gt;
                              &lt;Rectangle x:Name=&quot;PART_DisabledVisual&quot; Fill=&quot;#A5FFFFFF&quot; Stretch=&quot;Fill&quot; Stroke=&quot;#A5FFFFFF&quot; StrokeThickness=&quot;1&quot; RadiusX=&quot;2&quot; RadiusY=&quot;2&quot; Opacity=&quot;0&quot; Visibility=&quot;Collapsed&quot;/&gt;
                          &lt;/Grid&gt;
                          &lt;ControlTemplate.Triggers&gt;
                              &lt;Trigger Property=&quot;IsEnabled&quot; Value=&quot;False&quot;&gt;
                                  &lt;Setter Property=&quot;Visibility&quot; TargetName=&quot;PART_DisabledVisual&quot; Value=&quot;Visible&quot;/&gt;
                              &lt;/Trigger&gt;
                              &lt;DataTrigger Binding=&quot;{Binding DisplayMode, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type Custom:Calendar}}}&quot; Value=&quot;Year&quot;&gt;
                                  &lt;Setter Property=&quot;Visibility&quot; TargetName=&quot;PART_MonthView&quot; Value=&quot;Hidden&quot;/&gt;
                                  &lt;Setter Property=&quot;Visibility&quot; TargetName=&quot;PART_YearView&quot; Value=&quot;Visible&quot;/&gt;
                              &lt;/DataTrigger&gt;
                              &lt;DataTrigger Binding=&quot;{Binding DisplayMode, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type Custom:Calendar}}}&quot; Value=&quot;Decade&quot;&gt;
                                  &lt;Setter Property=&quot;Visibility&quot; TargetName=&quot;PART_MonthView&quot; Value=&quot;Hidden&quot;/&gt;
                                  &lt;Setter Property=&quot;Visibility&quot; TargetName=&quot;PART_YearView&quot; Value=&quot;Visible&quot;/&gt;
                              &lt;/DataTrigger&gt;
                          &lt;/ControlTemplate.Triggers&gt;
                      &lt;/ControlTemplate&gt;
                  &lt;/Setter.Value&gt;
              &lt;/Setter&gt;
          &lt;/Style&gt;
          &lt;ControlTemplate x:Key=&quot;ButtonControlTemplate1&quot; TargetType=&quot;{x:Type Button}&quot;&gt;
              &lt;Grid Cursor=&quot;Hand&quot;&gt;
                  &lt;VisualStateManager.VisualStateGroups&gt;
                      &lt;VisualStateGroup x:Name=&quot;CommonStates&quot;&gt;
                          &lt;VisualState x:Name=&quot;Normal&quot;/&gt;
                          &lt;VisualState x:Name=&quot;MouseOver&quot;&gt;
                              &lt;Storyboard&gt;
                                  &lt;ColorAnimation Duration=&quot;00:00:00&quot; Storyboard.TargetName=&quot;TextColor&quot; Storyboard.TargetProperty=&quot;Color&quot; To=&quot;#FF73A9D8&quot;/&gt;
                              &lt;/Storyboard&gt;
                          &lt;/VisualState&gt;
                          &lt;VisualState x:Name=&quot;Disabled&quot;&gt;
                              &lt;Storyboard&gt;
                                  &lt;DoubleAnimation Duration=&quot;00:00:00&quot; Storyboard.TargetName=&quot;buttonContent&quot; Storyboard.TargetProperty=&quot;Opacity&quot; To=&quot;0.5&quot;/&gt;
                              &lt;/Storyboard&gt;
                          &lt;/VisualState&gt;
                      &lt;/VisualStateGroup&gt;
                  &lt;/VisualStateManager.VisualStateGroups&gt;
                  &lt;ContentPresenter x:Name=&quot;buttonContent&quot; HorizontalAlignment=&quot;{TemplateBinding HorizontalContentAlignment}&quot; Margin=&quot;1,4,1,9&quot; VerticalAlignment=&quot;{TemplateBinding VerticalContentAlignment}&quot; TextElement.Foreground=&quot;#FF333333&quot; Content=&quot;{TemplateBinding Content}&quot; ContentTemplate=&quot;{TemplateBinding ContentTemplate}&quot;/&gt;
              &lt;/Grid&gt;
          &lt;/ControlTemplate&gt;
      &lt;/Window.Resources&gt;
  
      &lt;Grid x:Name=&quot;LayoutRoot&quot;&gt;
          &lt;Custom:Calendar HorizontalAlignment=&quot;Left&quot; VerticalAlignment=&quot;Top&quot; Style=&quot;{DynamicResource CalendarStyle1}&quot;/&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>