WPF DatePicker default to today's date

Viewed 101100

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;

or

datePicker.DisplayDate = DateTime.Now.Date;
7 Answers

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

the date today is represented in "DateTime.Today"

datePicker.SelectedDate=DateTime.Now;

Related