title | description | ms.date | helpviewer_keywords | ms.assetid | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Calendar Styles and Templates |
Learn about calendar styles and templates for the Calendar control. You can modify the default ControlTemplate to give the control a unique appearance. |
03/30/2017 |
|
f4fcf046-7a8f-41b8-b5a8-534b64e0345c |
This topic describes the styles and templates for the xref:System.Windows.Controls.Calendar control. You can modify the default xref:System.Windows.Controls.ControlTemplate to give the control a unique appearance. For more information, see Create a template for a control.
The following table lists the named parts for the xref:System.Windows.Controls.Calendar control.
Part | Type | Description |
---|---|---|
PART_CalendarItem | xref:System.Windows.Controls.Primitives.CalendarItem | The currently displayed month or year on the xref:System.Windows.Controls.Calendar. |
PART_Root | xref:System.Windows.Controls.Panel | The panel that contains the xref:System.Windows.Controls.Primitives.CalendarItem. |
The following table lists the visual states for the xref:System.Windows.Controls.Calendar control.
VisualState Name | VisualStateGroup Name | Description |
---|---|---|
Valid | ValidationStates | The control uses the xref:System.Windows.Controls.Validation class and the xref:System.Windows.Controls.Validation.HasError%2A?displayProperty=nameWithType attached property is false . |
InvalidFocused | ValidationStates | The xref:System.Windows.Controls.Validation.HasError%2A?displayProperty=nameWithType attached property is true has the control has focus. |
InvalidUnfocused | ValidationStates | The xref:System.Windows.Controls.Validation.HasError%2A?displayProperty=nameWithType attached property is true has the control does not have focus. |
The following table lists the named parts for the xref:System.Windows.Controls.Primitives.CalendarItem control.
Part | Type | Description |
---|---|---|
PART_Root | xref:System.Windows.FrameworkElement | The root of the control. |
PART_PreviousButton | xref:System.Windows.Controls.Button | The button that displays the previous page of the calendar when it is clicked. |
PART_NextButton | xref:System.Windows.Controls.Button | The button that displays the next page of the calendar when it is clicked. |
PART_HeaderButton | xref:System.Windows.Controls.Button | The button that allows switching between month mode, year mode, and decade mode. |
PART_MonthView | xref:System.Windows.Controls.Grid | Hosts the content when in month mode. |
PART_YearView | xref:System.Windows.Controls.Grid | Hosts the content when in year or decade mode. |
PART_DisabledVisual | xref:System.Windows.FrameworkElement | The overlay for the disabled state. |
DayTitleTemplate | xref:System.Windows.DataTemplate | The xref:System.Windows.DataTemplate that describes the visual structure. |
The following table lists the visual states for the xref:System.Windows.Controls.Primitives.CalendarItem control.
VisualState Name | VisualStateGroup Name | Description |
---|---|---|
Normal State | CommonStates | The default state. |
Disabled State | CommonStates | The state of the calendar when the xref:System.Windows.UIElement.IsEnabled%2A property is false . |
Valid | ValidationStates | The control uses the xref:System.Windows.Controls.Validation class and the xref:System.Windows.Controls.Validation.HasError%2A?displayProperty=nameWithType attached property is false . |
InvalidFocused | ValidationStates | The xref:System.Windows.Controls.Validation.HasError%2A?displayProperty=nameWithType attached property is true has the control has focus. |
InvalidUnfocused | ValidationStates | The xref:System.Windows.Controls.Validation.HasError%2A?displayProperty=nameWithType attached property is true has the control does not have focus. |
Valid | ValidationStates | The control uses the xref:System.Windows.Controls.Validation class and the xref:System.Windows.Controls.Validation.HasError%2A?displayProperty=nameWithType attached property is false . |
InvalidFocused | ValidationStates | The xref:System.Windows.Controls.Validation.HasError%2A?displayProperty=nameWithType attached property is true has the control has focus. |
InvalidUnfocused | ValidationStates | The xref:System.Windows.Controls.Validation.HasError%2A?displayProperty=nameWithType attached property is true has the control does not have focus. |
The xref:System.Windows.Controls.Primitives.CalendarDayButton control does not have any named parts.
The following table lists the visual states for the xref:System.Windows.Controls.Primitives.CalendarDayButton control.
VisualState Name | VisualStateGroup Name | Description |
---|---|---|
Normal | CommonStates | The default state. |
Disabled | CommonStates | The xref:System.Windows.Controls.Primitives.CalendarDayButton is disabled. |
MouseOver | CommonStates | The mouse pointer is positioned over the xref:System.Windows.Controls.Primitives.CalendarDayButton. |
Pressed | CommonStates | The xref:System.Windows.Controls.Primitives.CalendarDayButton 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 xref:System.DateTime.Today%2A?displayProperty=nameWithType. |
Today | DayStates | The button represents xref:System.DateTime.Today%2A?displayProperty=nameWithType. |
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 xref:System.Windows.Controls.Validation class and the xref:System.Windows.Controls.Validation.HasError%2A?displayProperty=nameWithType attached property is false . |
InvalidFocused | ValidationStates | The xref:System.Windows.Controls.Validation.HasError%2A?displayProperty=nameWithType attached property is true has the control has focus. |
InvalidUnfocused | ValidationStates | The xref:System.Windows.Controls.Validation.HasError%2A?displayProperty=nameWithType attached property is true has the control does not have focus. |
The xref:System.Windows.Controls.Primitives.CalendarButton control does not have any named parts.
The following table lists the visual states for the xref:System.Windows.Controls.Primitives.CalendarButton control.
VisualState Name | VisualStateGroup Name | Description |
---|---|---|
Normal | CommonStates | The default state. |
Disabled | CommonStates | The xref:System.Windows.Controls.Primitives.CalendarButton is disabled. |
MouseOver | CommonStates | The mouse pointer is positioned over the xref:System.Windows.Controls.Primitives.CalendarButton. |
Pressed | CommonStates | The xref:System.Windows.Controls.Primitives.CalendarButton 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 xref:System.Windows.Controls.Validation class and the xref:System.Windows.Controls.Validation.HasError%2A?displayProperty=nameWithType attached property is false . |
InvalidFocused | ValidationStates | The xref:System.Windows.Controls.Validation.HasError%2A?displayProperty=nameWithType attached property is true has the control has focus. |
InvalidUnfocused | ValidationStates | The xref:System.Windows.Controls.Validation.HasError%2A?displayProperty=nameWithType attached property is true has the control does not have focus. |
The following example shows how to define a xref:System.Windows.Controls.ControlTemplate for the xref:System.Windows.Controls.Calendar control and associated types.
[!code-xamlControlTemplateExamples#Calendar]
The preceding example uses one or more of the following resources.
[!code-xamlControlTemplateExamples#Resources]
For the complete sample, see Styling with ControlTemplates Sample.
- xref:System.Windows.FrameworkElement.Style%2A
- xref:System.Windows.Controls.ControlTemplate
- Control Styles and Templates
- Control Customization
- Styling and Templating
- Create a template for a control