MonthFormat property

DatePicker.MonthFormat property

Gets or sets the display format for the month value.

Syntax


Public Property MonthFormat As String


<DatePicker MonthFormat="formatString"/>

XAML Values

formatString

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

Property value

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

The display format for the month value.

Remarks

Change the format of the month picker by setting the MonthFormat property.

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

format patternformat template
{month.integer} | {month.integer(n)} month.numeric
{month.full} | {month.abbreviated} | {month.abbreviated(n)}month | month.full | month.abbreviated

 

In some cases, using a format pattern gives you more precise control over the formatting. For example, you can use a format pattern to specify that the month picker always shows 2 digits, including a leading 0 when needed. You can also combine multiple format patterns. For example, you can combine the {month.integer} and {month.abbreviated} formats to make the month picker show the month number and name, like this: 12 Dec. See the Examples section for more info.

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 DatePicker controls 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}"/>

Here's a DatePicker that combines 2 format patterns to display both the month number and name in the month picker. There is no equivalent format template for this format.


<DatePicker MonthFormat="{}{month.integer} {month.abbreviated}"/>

Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

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

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

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
DayFormat
YearFormat
MonthVisible
Quickstart: Adding a DatePicker
How to use patterns to format dates and times

 

 

Show:
© 2016 Microsoft