Allows users to pick a date value.
Syntax
<div data-win-control="WinJS.UI.DatePicker"></div>
var datePicker = new WinJS.UI.DatePicker(element, options);
Members
The DatePicker object has these types of members:
Events
The DatePicker object has these events.
| Event | Description |
|---|---|
| onchange |
Occurs when any of the controls are changed by the user. |
Methods
The DatePicker object has these methods.
| Method | Description |
|---|---|
| addEventListener |
Adds an event listener. |
| DatePicker |
Initializes a new instance of the DatePicker control. |
| dispatchEvent |
Raises an event of the specified type and with additional properties. |
| raiseEvent |
Raises an event of the specified type and with additional properties. |
| removeEventListener |
Removes a listener for the specified event. |
Properties
The DatePicker object has these properties.
| Property | Description |
|---|---|
|
Gets or sets the calendar to use. | |
|
Gets or sets the current date of the DatePicker. You can use either a date string or a Date object to set this property. | |
|
Gets or sets the display pattern for the date. The default date pattern is day.integer(2). You can change the date pattern by changing the number of integers displayed. | |
|
Specifies whether the DatePicker is disabled. | |
|
Gets the DOM element for the DatePicker. | |
|
Gets or sets the maximum Gregorian year available for picking. | |
|
Gets or sets the minimum Gregorian year available for picking. | |
|
Gets or sets the display pattern for the month. The default month pattern is month.abbreviated. You can change the month pattern to the following values:
| |
|
Gets or sets the display pattern for the year. The default year pattern is year.full. You can change the year pattern to the following values:
|
Remarks
To find out more about the DatePicker, see Quickstart: Adding a DatePicker.
For more information about using the DatePicker, see the Date and time picker sample at Windows Store app samples.
Styling the DatePicker
CSS classes
To customize a DatePicker, you can define your own styles for these CSS classes (defined by the Windows Library for JavaScript style sheets):
| CSS class | Description |
|---|---|
|
win-datepicker |
Styles the entire DatePicker control. |
|
win-datepicker-date |
Styles the date control. |
|
win-datepicker-month |
Styles the month control. |
|
win-datepicker-year |
Styles the year control. |
You can also customize the DatePicker by determining the order of the day/month/year elements. Use the win-order CSS class to specify the order. For example, to specify that the year control should appear first, you would specify win-order0.
Examples
The following code shows how to instantiate a DatePicker declaratively and then get a reference to it in the code by using the special winControl property. You can use this property only on elements that host a Windows Library for JavaScript (WinJS) control. For more information, see Quickstart: adding WinJS controls and styles .
<div id="date" data-win-control="WinJS.UI.DatePicker"></div> <script type="text/javascript"> WinJS.UI.processAll(); var control = document.getElementByID("date").winControl; </script>
The following code shows how to instantiate a DatePicker programmatically.
<div id="date"></div> <script type="text/javascript"> var dateDiv = document.getElementById("date"); var datePicker = new WinJS.UI.DatePicker(dateDiv); </script>
Requirements
|
Minimum supported client | Windows 8 [Windows Store apps only] |
|---|---|
|
Minimum supported server | Windows Server 2012 [Windows Store apps only] |
|
Namespace |
WinJS.UI |
|
Library |
|
Build date: 12/5/2012