title: Change foreground color of calendar items
body: <p>I'm customizing a calendar control in WPF and I'm able to adjust the background color, header foreground colors etc.. But I can't find how to edit the appearance of the 1-31 day calendar items. At the</p>
  
  <p>Screenshot:</p>
  
  <p><img src="https://i.stack.imgur.com/ZlcSA.png" alt="enter image description here"></p>
  
  <p>As you can see, the numbers are all dark grey and almost not readable. I would also like to get the rid of the blue-ish overlay on mouseover.</p>
  
  <p>Code:</p>
  
  <pre><code>&lt;Window x:Class="WPFDatePickerSample.Window2"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Title="Window2" Height="500" Width="500"
      Background="#2F2F2F"&gt;
  
  &lt;Window.Resources&gt;
      &lt;Style TargetType="{x:Type CalendarItem}"&gt;
          &lt;Setter Property="Margin" Value="50"/&gt;
  
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="{x:Type CalendarItem}"&gt;
                      &lt;ControlTemplate.Resources&gt;
                          &lt;DataTemplate x:Key="{x:Static CalendarItem.DayTitleTemplateResourceKey}"&gt;
                              &lt;TextBlock Foreground="#FFA9C822" FontWeight="Normal" FontSize="12" HorizontalAlignment="Center" Margin="0,5,0,5" Text="{Binding}" VerticalAlignment="Center"/&gt;
                          &lt;/DataTemplate&gt;
                      &lt;/ControlTemplate.Resources&gt;
  
                      &lt;Grid x:Name="PART_Root"&gt;
                          &lt;Grid.Resources&gt;
                              &lt;SolidColorBrush x:Key="DisabledColor" Color="#A5FFFFFF"/&gt;
                          &lt;/Grid.Resources&gt;
  
                          &lt;VisualStateManager.VisualStateGroups&gt;
                              &lt;VisualStateGroup x:Name="CommonStates"&gt;
                                  &lt;VisualState x:Name="Normal"/&gt;
                                  &lt;VisualState x:Name="Disabled"&gt;
                                      &lt;Storyboard&gt;
                                          &lt;DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_DisabledVisual"/&gt;
                                      &lt;/Storyboard&gt;
                                  &lt;/VisualState&gt;
                              &lt;/VisualStateGroup&gt;
                          &lt;/VisualStateManager.VisualStateGroups&gt;
  
                          &lt;Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="1"&gt;
                              &lt;Border BorderBrush="#FFFFFFFF" BorderThickness="0" CornerRadius="0"&gt;
                                  &lt;Grid&gt;
                                      &lt;Grid.Resources&gt;
                                          &lt;ControlTemplate x:Key="PreviousButtonTemplate" TargetType="{x:Type Button}"&gt;
                                              &lt;Grid Cursor="Hand"&gt;
                                                  &lt;VisualStateManager.VisualStateGroups&gt;
                                                      &lt;VisualStateGroup x:Name="CommonStates"&gt;
                                                          &lt;VisualState x:Name="Normal"/&gt;
                                                          &lt;VisualState x:Name="MouseOver"&gt;
                                                              &lt;Storyboard&gt;
                                                                  &lt;ColorAnimation Duration="0" To="#FFA9C822" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="path"/&gt;
                                                              &lt;/Storyboard&gt;
                                                          &lt;/VisualState&gt;
                                                          &lt;VisualState x:Name="Disabled"&gt;
                                                              &lt;Storyboard&gt;
                                                                  &lt;DoubleAnimation Duration="0" To=".5" Storyboard.TargetProperty="(Shape.Fill).(Brush.Opacity)" Storyboard.TargetName="path"/&gt;
                                                              &lt;/Storyboard&gt;
                                                          &lt;/VisualState&gt;
                                                      &lt;/VisualStateGroup&gt;
                                                  &lt;/VisualStateManager.VisualStateGroups&gt;
  
                                                  &lt;Rectangle Fill="Transparent" Opacity="1" Stretch="Fill"/&gt;
  
                                                  &lt;Grid&gt;
                                                      &lt;Path x:Name="path" Data="M288.75,232.25 L288.75,240.625 L283,236.625 z" Fill="Silver" HorizontalAlignment="Left" Height="10" Margin="5,-6,0,0" Stretch="Fill" VerticalAlignment="Center" Width="6"/&gt;
                                                  &lt;/Grid&gt;
                                              &lt;/Grid&gt;
                                          &lt;/ControlTemplate&gt;
  
                                          &lt;ControlTemplate x:Key="NextButtonTemplate" TargetType="{x:Type Button}"&gt;
                                              &lt;Grid Cursor="Hand"&gt;
                                                  &lt;VisualStateManager.VisualStateGroups&gt;
                                                      &lt;VisualStateGroup x:Name="CommonStates"&gt;
                                                          &lt;VisualState x:Name="Normal"/&gt;
                                                          &lt;VisualState x:Name="MouseOver"&gt;
                                                              &lt;Storyboard&gt;
                                                                  &lt;ColorAnimation Duration="0" To="#FFA9C822" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="path"/&gt;
                                                              &lt;/Storyboard&gt;
                                                          &lt;/VisualState&gt;
  
                                                          &lt;VisualState x:Name="Disabled"&gt;
                                                              &lt;Storyboard&gt;
                                                                  &lt;DoubleAnimation Duration="0" To=".5" Storyboard.TargetProperty="(Shape.Fill).(Brush.Opacity)" Storyboard.TargetName="path"/&gt;
                                                              &lt;/Storyboard&gt;
                                                          &lt;/VisualState&gt;
                                                      &lt;/VisualStateGroup&gt;
                                                  &lt;/VisualStateManager.VisualStateGroups&gt;
  
                                                  &lt;Rectangle Fill="Transparent" Opacity="1" Stretch="Fill"/&gt;
  
                                                  &lt;Grid&gt;
                                                      &lt;Path x:Name="path" Data="M282.875,231.875 L282.875,240.375 L288.625,236 z" Fill="Silver" HorizontalAlignment="Right" Height="10" Margin="0,-6,5,0" Stretch="Fill" VerticalAlignment="Center" Width="6"/&gt;
                                                  &lt;/Grid&gt;
                                              &lt;/Grid&gt;
                                          &lt;/ControlTemplate&gt;
  
                                          &lt;ControlTemplate x:Key="HeaderButtonTemplate" TargetType="{x:Type Button}"&gt;
                                              &lt;Grid Cursor="Hand"&gt;
                                                  &lt;VisualStateManager.VisualStateGroups&gt;
                                                      &lt;VisualStateGroup x:Name="CommonStates"&gt;
                                                          &lt;VisualState x:Name="Normal"/&gt;
                                                          &lt;VisualState x:Name="MouseOver"&gt;
                                                              &lt;Storyboard&gt;
                                                                  &lt;DoubleAnimation Duration="0" To=".7" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="buttonContent"/&gt;
                                                              &lt;/Storyboard&gt;
                                                          &lt;/VisualState&gt;
  
                                                          &lt;VisualState x:Name="Disabled"&gt;
                                                              &lt;Storyboard&gt;
                                                                  &lt;DoubleAnimation Duration="0" To=".5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="buttonContent"/&gt;
                                                              &lt;/Storyboard&gt;
                                                          &lt;/VisualState&gt;
                                                      &lt;/VisualStateGroup&gt;
                                                  &lt;/VisualStateManager.VisualStateGroups&gt;
  
                                                  &lt;ContentPresenter x:Name="buttonContent" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" TextElement.Foreground="Silver" TextElement.FontFamily="Segoe UI" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="1,3,1,9" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/&gt;
                                              &lt;/Grid&gt;
                                          &lt;/ControlTemplate&gt;
                                      &lt;/Grid.Resources&gt;
  
                                      &lt;Grid.ColumnDefinitions&gt;
                                          &lt;ColumnDefinition Width="Auto"/&gt;
                                          &lt;ColumnDefinition Width="Auto"/&gt;
                                          &lt;ColumnDefinition Width="Auto"/&gt;
                                      &lt;/Grid.ColumnDefinitions&gt;
  
                                      &lt;Grid.RowDefinitions&gt;
                                          &lt;RowDefinition Height="Auto"/&gt;
                                          &lt;RowDefinition Height="*"/&gt;
                                      &lt;/Grid.RowDefinitions&gt;
  
                                      &lt;Grid Grid.Row="0" Grid.ColumnSpan="4" Background="#3C3C3C" HorizontalAlignment="Stretch"&gt;
                                          &lt;Button x:Name="PART_PreviousButton" Grid.Column="0" Focusable="False" HorizontalAlignment="Left" Height="20" Grid.Row="0" Template="{StaticResource PreviousButtonTemplate}" Width="28"/&gt;
                                          &lt;Button x:Name="PART_HeaderButton" Grid.Column="1" FontWeight="Normal" Focusable="False" FontSize="13" HorizontalAlignment="Center" Grid.Row="0" Template="{StaticResource HeaderButtonTemplate}" VerticalAlignment="Center" /&gt;
                                          &lt;Button x:Name="PART_NextButton" Grid.Column="2" Focusable="False" HorizontalAlignment="Right" Height="20" Grid.Row="0" Template="{StaticResource NextButtonTemplate}" Width="28"/&gt;
                                      &lt;/Grid&gt;
                                      &lt;Grid x:Name="PART_MonthView" Grid.ColumnSpan="3" HorizontalAlignment="Center" Margin="6,-1,6,6" Grid.Row="1" Visibility="Visible"&gt;
                                          &lt;Grid.ColumnDefinitions&gt;
                                              &lt;ColumnDefinition Width="Auto"/&gt;
                                              &lt;ColumnDefinition Width="Auto"/&gt;
                                              &lt;ColumnDefinition Width="Auto"/&gt;
                                              &lt;ColumnDefinition Width="Auto"/&gt;
                                              &lt;ColumnDefinition Width="Auto"/&gt;
                                              &lt;ColumnDefinition Width="Auto"/&gt;
                                              &lt;ColumnDefinition Width="Auto"/&gt;
                                          &lt;/Grid.ColumnDefinitions&gt;
  
                                          &lt;Grid.RowDefinitions&gt;
                                              &lt;RowDefinition Height="Auto"/&gt;
                                              &lt;RowDefinition Height="Auto"/&gt;
                                              &lt;RowDefinition Height="Auto"/&gt;
                                              &lt;RowDefinition Height="Auto"/&gt;
                                              &lt;RowDefinition Height="Auto"/&gt;
                                              &lt;RowDefinition Height="Auto"/&gt;
                                              &lt;RowDefinition Height="Auto"/&gt;
                                          &lt;/Grid.RowDefinitions&gt;
                                      &lt;/Grid&gt;
  
                                      &lt;Grid x:Name="PART_YearView" Grid.ColumnSpan="3" HorizontalAlignment="Center" Margin="6,-3,7,6" Grid.Row="1" Visibility="Hidden"&gt;
                                          &lt;Grid.ColumnDefinitions&gt;
                                              &lt;ColumnDefinition Width="Auto"/&gt;
                                              &lt;ColumnDefinition Width="Auto"/&gt;
                                              &lt;ColumnDefinition Width="Auto"/&gt;
                                              &lt;ColumnDefinition Width="Auto"/&gt;
                                          &lt;/Grid.ColumnDefinitions&gt;
  
                                          &lt;Grid.RowDefinitions&gt;
                                              &lt;RowDefinition Height="Auto"/&gt;
                                              &lt;RowDefinition Height="Auto"/&gt;
                                              &lt;RowDefinition Height="Auto"/&gt;
                                          &lt;/Grid.RowDefinitions&gt;
                                      &lt;/Grid&gt;
                                  &lt;/Grid&gt;
                              &lt;/Border&gt;
                          &lt;/Border&gt;
  
                          &lt;Rectangle x:Name="PART_DisabledVisual" Fill="{StaticResource DisabledColor}" Opacity="0" RadiusY="2" RadiusX="2" Stretch="Fill" Stroke="{StaticResource DisabledColor}" StrokeThickness="1" Visibility="Collapsed"/&gt;
                      &lt;/Grid&gt;
  
                      &lt;ControlTemplate.Triggers&gt;
                          &lt;Trigger Property="IsEnabled" Value="False"&gt;
                              &lt;Setter Property="Visibility" TargetName="PART_DisabledVisual" Value="Visible" /&gt;
                          &lt;/Trigger&gt;
  
                          &lt;DataTrigger Binding="{Binding DisplayMode, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Calendar}}}" Value="Year"&gt;
                              &lt;Setter Property="Visibility" TargetName="PART_MonthView" Value="Hidden" /&gt;
                              &lt;Setter Property="Visibility" TargetName="PART_YearView" Value="Visible" /&gt;
                          &lt;/DataTrigger&gt;
  
                          &lt;DataTrigger Binding="{Binding DisplayMode, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Calendar}}}" Value="Decade"&gt;
                              &lt;Setter Property="Visibility" TargetName="PART_MonthView" Value="Hidden" /&gt;
                              &lt;Setter Property="Visibility" TargetName="PART_YearView" Value="Visible" /&gt;
                          &lt;/DataTrigger&gt;
                      &lt;/ControlTemplate.Triggers&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
  
      &lt;Style TargetType="{x:Type Calendar}"&gt;
          &lt;Setter Property="Background" Value="#3C3C3C"/&gt;
  
          &lt;Setter Property="SnapsToDevicePixels" Value="True" /&gt;
          &lt;Setter Property="BorderBrush" Value="Transparent" /&gt;
          &lt;Setter Property="BorderThickness" Value="1" /&gt;
  
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="{x:Type Calendar}"&gt;
                      &lt;StackPanel x:Name="PART_Root" HorizontalAlignment="Center"&gt;
                          &lt;CalendarItem x:Name="PART_CalendarItem" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" /&gt;
                      &lt;/StackPanel&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
  &lt;/Window.Resources&gt;
  
  &lt;Grid&gt;
      &lt;Calendar Width="400" Height="400"&gt;&lt;/Calendar&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>