DatePicker.YearFormat property

Applies to Windows and Windows Phone

Gets or sets the display format for the year value.

Syntax


public:
property String^ YearFormat { 
   String^ get();
   void set (String^ value);
}


<DatePicker YearFormat="formatString"/>

XAML Values

formatString

The string format to use to display the year. See Remarks.

Property value

Type: System.String [.NET] | Platform::String [C++]

The display format for the year value.

Remarks

Change the format of the year picker by setting the YearFormat property.

The string content of each ComboBox in the DatePicker is created by a DateTimeFormatter. You inform the DateTimeFormatter how to format the year value by providing a string that is either a format template or a format pattern. Common templates and patterns for year values are listed in the following table.

format patternformat template
{year.full} | {year.abbreviated} | {year.abbreviated(n)}year | year.full | year.abbreviated
{era.full} | {era.abbreviated} | {era.abbreviated(n)}n/a

 

Note  "Era" only applies when the CalendarIdentifier is set to the Japanese calendar. For the Japanese calendar, era is shown in the year picker.

For the complete list of format templates and format patterns, see the Remarks section of the DateTimeFormatter class documentation.

Examples

Here's a DatePicker formatted using format templates, and a DatePicker formatted using format strings. Both DatePickers look the same when the app is run because the formatting is equivalent.


<!-- DatePicker formatted using format templates. -->
<DatePicker DayFormat="day" MonthFormat="month.numeric" YearFormat="year.abbreviated"/>

<!-- DatePicker formatted using format patterns. -->
<DatePicker DayFormat="{}{day.integer}" MonthFormat="{}{month.integer}" YearFormat="{}{year.abbreviated}"/>

Requirements

Minimum supported client

Windows 8.1

Minimum supported server

Windows Server 2012 R2

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml.Controls
Windows::UI::Xaml::Controls [C++]

Metadata

Windows.winmd

See also

DatePicker
DateTimeFormatter
Quickstart: Adding a DatePicker
How to use patterns to format dates and times

 

 

Show:
© 2014 Microsoft