WPF DatePicker default to today's date

WPF DatePicker always show 'Show Calendar' by default. I want it to show current/todays date. How do I do that. I tried doing something like the below in the constructor but it won't work,

datePicker.SelectedDate = DateTime.Now.Date;


datePicker.DisplayDate = DateTime.Now.Date;

please try with this ....

<my:DatePicker SelectedDate="{x:Static sys:DateTime.Now}"/>

add this reference


I have the following DatePicker control in my project: <DatePicker x:Name="startDate" SelectedDate="2013-04-03"></DatePicker> QUESTION: Is it possible to set the DatePicker.SelectedDate using only XAML? I know this can be achieved using code-behind.

The below works for me. (dpDate is my DatePicker control)

public MainWindow()
    dpDate.SelectedDate = DateTime.Today;            

WPF - Datepicker - A DatePicker is a control that allows a user to pick a date value. The user picks the date by using ComboBox selection for month, day, and year values.

Couple of options...

You could copy the entire style for the DatePicker control and edit the XAML and use that as the default resource making the TargetType DatePicker which will force it to be used across the application.

You could also edit the style locally and place your own TextBox in the style and hide the DatePickerTextBox and then setup the binding appropriately.

Some in depth conversation here with a pretty good explanation by ericf at the top.

The following example creates a DatePicker that is initialized with its calendar open and displaying July 7, 2009. <DatePicker IsDropDownOpen="True" IsTodayHighlighted="False" DisplayDate="7/7/09"/> Remarks. This property affects the Calendar of the DatePicker. For more information, see the Calendar.DisplayDate property.

You can use the DatePicker's Text property to get or set the date http://msdn.microsoft.com/en-us/library/system.windows.controls.datepicker.text.aspx

I'm developing with IronPython and do it as so

self.root.FindName('DatePicker').Text = time.strftime('%m/%d/%Y')

The DisplayDate property represents the date to display. The default is today. IsDropDownOpen The IsDropDownOpen property indicates whether the calendar part of the DatePicker control is open or closed. Text Property The Text property represents the text that is displayed in the DatePicker. Selection Date and Selection Date Format

the issue is you are attempting to access date with time. that doesn't work.

the date today is represented in "DateTime.Today"

WPF DatePicker always show 'Show Calendar' by default. I want it to show current/todays date. How do I do that. I tried doing something like the below in the constructor but it won't work, datePic

A DatePicker control is used to create a visual DatePicker that let user to pick a date and fire an event on the selection of the date. The DatePicker class in C# and &lt;DatePicker&gt; element in XAML represent a WPF DatePicker control. This code example in this article demonstrates how to create and use a DatePicker control in WPF with the help of XAML and C#.

You can use a global variable to store the date that is bound to the Default property in the date picker, and in the prev/next buttons you'd decrement/increment the variable value. In the app's OnStart property (you can find it on the first screen of your app), you'd need to initialize that value: <first screen>.OnStart: Set(defaultDate, Today())

Overview. Would you like to customize the date time field date options in WPForms? The Date / Time field includes two format options for the date selector: Date Picker, which provides the user with a calendar, or Date Dropdown.