I wish the dropdown to show me years instead of the date of today at the start. Remark: Standard WPF DatePicker has no "DisplayMode" as shown in other sources.
Asked
Active
Viewed 3,611 times
1
-
1This could be helpful: http://stackoverflow.com/questions/1798513/wpf-toolkit-datepicker-month-year-only – e_ne Jan 04 '13 at 18:44
3 Answers
1
dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "YYYY dd, mmmm - dddd";
OR:
dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "YYYY mm, dddd - dddd";
For a more expanded explanation, you can click here.

Brian
- 5,069
- 7
- 37
- 47
-
The Format and CustomFormat only exists in Windows Forms. WPF has no equivalent. – DJ van Wyk Sep 08 '15 at 10:15
1
Thank you very much for your answers but I found a solution which I am more content with (using just the standart control)
<DatePicker x:Name="_DatePicker" CalendarOpened="_DatePicker_CalendarOpened" />
private void _DatePicker_CalendarOpened(object sender, RoutedEventArgs e) {
// Finding the calendar that is child of stadart WPF DatePicker
DatePicker datepicker = (DatePicker)sender;
Popup popup = (Popup)datepicker.Template.FindName("PART_Popup", datepicker);
System.Windows.Controls.Calendar cal = (System.Windows.Controls.Calendar)popup.Child;
cal.DisplayMode = System.Windows.Controls.CalendarMode.Decade;
}
Good Day and Thx
0
If you use WPF toolkit then
<toolkit:Calendar x:Name="yearCalender" DisplayModeChanged="yearCalender_DisplayModeChanged" DisplayMode="Year" />
C# code:
private void yearCalender_DisplayModeChanged(System.Object sender, Microsoft.Windows.Controls.CalendarModeChangedEventArgs e)
{
yearCalender.DisplayMode = Microsoft.Windows.Controls.CalendarMode.Year;
}

Kishore Kumar
- 12,675
- 27
- 97
- 154