DatePicker.Date Property


Gets or sets the date currently set in the date picker.

Equivalent WinUI property: Microsoft.UI.Xaml.Controls.DatePicker.Date.

 property DateTime Date { DateTime get(); void set(DateTime value); };
DateTime Date();

void Date(DateTime value);
public System.DateTimeOffset Date { get; set; }
var dateTime =; = dateTime;
Public Property Date As DateTimeOffset

Property Value

DateTime DateTimeOffset

The date currently set in the picker.


This example demonstrates setting the Date property in code.

<DatePicker x:Name="myDatePicker"/>
public MainPage()
    myDatePicker.Date = new DateTimeOffset(new DateTime(1950, 1, 1));


The date picker control has both Date and SelectedDate properties. The difference between these is that Date is not nullable, while SelectedDate is nullable.

The value of SelectedDate is used to populate the date picker and is null by default. If SelectedDate is null, the Date property is set to 12/31/1600; otherwise, the Date value is synchronized with the SelectedDate value. When SelectedDate is null, the picker is 'unset' and shows the field names instead of a date.

To use the Date value in your app, you typically use a data binding to the Date property, or handle the DateChanged event.

The Date property can't be set as a XAML attribute string, because the Windows Runtime XAML parser doesn't have a conversion logic for converting strings to dates as DateTime / DateTimeOffset objects. Here are some suggested ways these objects can be defined in code and set to a date other than the current date.

Another possible technique is to define a date that's available as a data object or in the data context, then set Date as a XAML attribute that references a {Binding} markup extension that can access the date as data.

Applies to

See also