* Reset branch for WPF changes * Convert BMP to PNG; fix link-out-of-scope err * Add snippets for WPF... 6794 files!!!! * Add missing snippets * update file updated between migration * Fix paths to include * update breadcrumb and toc * fix index links * fix index links * fix index links * fix markdown
5.6 KiB
title, ms.date, helpviewer_keywords, ms.assetid
| title | ms.date | helpviewer_keywords | ms.assetid | ||||||
|---|---|---|---|---|---|---|---|---|---|
| DatePicker Styles and Templates | 03/30/2017 |
|
c430a657-692f-44bd-a549-2341f92d6115 |
DatePicker Styles and Templates
This topic describes the styles and templates for the xref:System.Windows.Controls.DatePicker 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.
DatePicker Parts
The following table lists the named parts for the xref:System.Windows.Controls.DatePicker control.
| Part | Type | Description |
|---|---|---|
| PART_Root | xref:System.Windows.Controls.Grid | The root of the control. |
| PART_Button | xref:System.Windows.Controls.Button | The button that opens and closes the xref:System.Windows.Controls.Calendar. |
| PART_TextBox | xref:System.Windows.Controls.Primitives.DatePickerTextBox | The text box that allows you to input a date. |
| PART_Popup | xref:System.Windows.Controls.Primitives.Popup | The popup for the xref:System.Windows.Controls.DatePicker control. |
DatePicker States
The following table lists the visual states for the xref:System.Windows.Controls.DatePicker control.
| VisualState Name | VisualStateGroup Name | Description |
|---|---|---|
| Normal | CommonStates | The default state. |
| Disabled | CommonStates | The xref:System.Windows.Controls.DatePicker is disabled. |
| 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. |
DatePickerTextBox Parts
The following table lists the named parts for the xref:System.Windows.Controls.Primitives.DatePickerTextBox control.
| Part | Type | Description |
|---|---|---|
| PART_Watermark | xref:System.Windows.Controls.ContentControl | The element that contains the initial text in the xref:System.Windows.Controls.DatePicker. |
| PART_ContentElement | xref:System.Windows.FrameworkElement | A visual element that can contain a xref:System.Windows.FrameworkElement. The text of the xref:System.Windows.Controls.TextBox is displayed in this element. |
DatePickerTextBox States
The following table lists the visual states for the xref:System.Windows.Controls.Primitives.DatePickerTextBox control.
| VisualState Name | VisualStateGroup Name | Description |
|---|---|---|
| Normal | CommonStates | The default state. |
| Disabled | CommonStates | The xref:System.Windows.Controls.Primitives.DatePickerTextBox is disabled. |
| MouseOver | CommonStates | The mouse pointer is positioned over the xref:System.Windows.Controls.Primitives.DatePickerTextBox. |
| ReadOnly | CommonStates | The user cannot change the text in the xref:System.Windows.Controls.Primitives.DatePickerTextBox. |
| Focused | FocusStates | The control has focus. |
| Unfocused | FocusStates | The control does not have focus. |
| Watermarked | WatermarkStates | The control displays its initial text. The xref:System.Windows.Controls.Primitives.DatePickerTextBox is in the state when the user has not entered text or selected a date. |
| Unwatermarked | WatermarkStates | The user has entered text into the xref:System.Windows.Controls.Primitives.DatePickerTextBox or selected a date in the xref:System.Windows.Controls.DatePicker. |
| 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 and the control has focus. |
| InvalidUnfocused | ValidationStates | The xref:System.Windows.Controls.Validation.HasError%2A?displayProperty=nameWithType attached property is true and the control does not have focus. |
DatePicker ControlTemplate Example
The following example shows how to define a xref:System.Windows.Controls.ControlTemplate for the xref:System.Windows.Controls.DatePicker control.
[!code-xamlControlTemplateExamples#DatePicker]
The preceding example uses one or more of the following resources.
[!code-xamlControlTemplateExamples#Resources]
For the complete sample, see Styling with ControlTemplates Sample.