--- title: "Calendar Styles and Templates" ms.date: "03/30/2017" helpviewer_keywords: - "styles [WPF], Calendar" - "templates [WPF], Calendar" - "states [WPF], Calendar" - "parts [WPF], Calendar" - "Calendar [WPF], styles and templates" - "ControlTemplate [WPF], Calendar" ms.assetid: f4fcf046-7a8f-41b8-b5a8-534b64e0345c --- # Calendar Styles and Templates This topic describes the styles and templates for the control. You can modify the default to give the control a unique appearance. For more information, see [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template). ## Calendar Parts The following table lists the named parts for the control. |Part|Type|Description| |-|-|-| |PART_CalendarItem||The currently displayed month or year on the .| |PART_Root||The panel that contains the .| ## Calendar States The following table lists the visual states for the control. |VisualState Name|VisualStateGroup Name|Description| |----------------------|---------------------------|-----------------| |Valid|ValidationStates|The control uses the class and the attached property is `false`.| |InvalidFocused|ValidationStates|The attached property is `true` has the control has focus.| |InvalidUnfocused|ValidationStates|The attached property is `true` has the control does not have focus.| ## CalendarItem Parts The following table lists the named parts for the control. |Part|Type|Description| |-|-|-| |PART_Root||The root of the control.| |PART_PreviousButton||The button that displays the previous page of the calendar when it is clicked.| |PART_NextButton||The button that displays the next page of the calendar when it is clicked.| |PART_HeaderButton||The button that allows switching between month mode, year mode, and decade mode.| |PART_MonthView||Hosts the content when in month mode.| |PART_YearView||Hosts the content when in year or decade mode.| |PART_DisabledVisual||The overlay for the disabled state.| |DayTitleTemplate||The that describes the visual structure.| ## CalendarItem States The following table lists the visual states for the control. |VisualState Name|VisualStateGroup Name|Description| |-|-|-| |Normal State|CommonStates|The default state.| |Disabled State|CommonStates|The state of the calendar when the property is `false`.| |Valid|ValidationStates|The control uses the class and the attached property is `false`.| |InvalidFocused|ValidationStates|The attached property is `true` has the control has focus.| |InvalidUnfocused|ValidationStates|The attached property is `true` has the control does not have focus.| |Valid|ValidationStates|The control uses the class and the attached property is `false`.| |InvalidFocused|ValidationStates|The attached property is `true` has the control has focus.| |InvalidUnfocused|ValidationStates|The attached property is `true` has the control does not have focus.| ## CalendarDayButton Parts The control does not have any named parts. ## CalendarDayButton States The following table lists the visual states for the control. |VisualState Name|VisualStateGroup Name|Description| |-|-|-| |Normal|CommonStates|The default state.| |Disabled|CommonStates|The is disabled.| |MouseOver|CommonStates|The mouse pointer is positioned over the .| |Pressed|CommonStates|The is pressed.| |Selected|SelectionStates|The button is selected.| |Unselected|SelectionStates|The button is not selected.| |CalendarButtonFocused|CalendarButtonFocusStates|The button has focus.| |CalendarButtonUnfocused|CalendarButtonFocusStates|The button does not have focus.| |Focused|FocusStates|The button has focus.| |Unfocused|FocusStates|The button does not have focus.| |Active|ActiveStates|The button is active.| |Inactive|ActiveStates|The button is inactive.| |RegularDay|DayStates|The button does not represent .| |Today|DayStates|The button represents .| |NormalDay|BlackoutDayStates|The button represents a day that can be selected.| |BlackoutDay|BlackoutDayStates|The button represents a day that cannot be selected.| |Valid|ValidationStates|The control uses the class and the attached property is `false`.| |InvalidFocused|ValidationStates|The attached property is `true` has the control has focus.| |InvalidUnfocused|ValidationStates|The attached property is `true` has the control does not have focus.| ## CalendarButton Parts The control does not have any named parts. ## CalendarButton States The following table lists the visual states for the control. |VisualState Name|VisualStateGroup Name|Description| |-|-|-| |Normal|CommonStates|The default state.| |Disabled|CommonStates|The is disabled.| |MouseOver|CommonStates|The mouse pointer is positioned over the .| |Pressed|CommonStates|The is pressed.| |Selected|SelectionStates|The button is selected.| |Unselected|SelectionStates|The button is not selected.| |CalendarButtonFocused|CalendarButtonFocusStates|The button has focus.| |CalendarButtonUnfocused|CalendarButtonFocusStates|The button does not have focus.| |Focused|FocusStates|The button has focus.| |Unfocused|FocusStates|The button does not have focus.| |Active|ActiveStates|The button is active.| |Inactive|ActiveStates|The button is inactive.| |Valid|ValidationStates|The control uses the class and the attached property is `false`.| |InvalidFocused|ValidationStates|The attached property is `true` has the control has focus.| |InvalidUnfocused|ValidationStates|The attached property is `true` has the control does not have focus.| ## Calendar ControlTemplate Example The following example shows how to define a for the control and associated types. [!code-xaml[ControlTemplateExamples#Calendar](~/samples/snippets/csharp/VS_Snippets_Wpf/ControlTemplateExamples/CS/resources/calendar.xaml#calendar)] The preceding example uses one or more of the following resources. [!code-xaml[ControlTemplateExamples#Resources](~/samples/snippets/csharp/VS_Snippets_Wpf/ControlTemplateExamples/CS/resources/shared.xaml#resources)] For the complete sample, see [Styling with ControlTemplates Sample](https://github.com/Microsoft/WPF-Samples/tree/master/Styles%20&%20Templates/IntroToStylingAndTemplating). ## See also - - - [Control Styles and Templates](control-styles-and-templates.md) - [Control Customization](control-customization.md) - [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview) - [Create a template for a control](/dotnet/desktop-wpf/themes/how-to-create-apply-template)