Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

WPF DatePicker.Displaydate problem when changing from Month to Year.

$
0
0

I am working on a VS 2010, .NET 4.0 WPF - MVVM application. I encountered a problem with the date shown by the calendar with the scenarios below.

Here are the steps to repro: This is not the actual code or pattern I am doing but it is enough to show the problem.

1.) Create a new WPF project.

2.) In the designer put a DatePicker and Button.

3.) Add a buttonClick event handler to the button. In the event handler set datePicker.DisplayDate = DateTime.Today.

Run the project.

1.) Now in the UI open the calendar from the datepicker and select a date from any other month but preferably a year from now. ex: March 1, 2014.

2.) After selecting a date, click the button to set the DisplayDate to today.

3.) Open again the calendar from the datepicker. At this point you will see that the calendar will correctly show February 2013.

4.) Now the problem is this: While the calendar is open click on the header (February 2013) to change the view from month to Year. When you click the header it incorrectly shows 2014 and, using my example, March is highlighted. Since the calendar started showing February 2013 shouldn't it show 2013 as well when the header was clicked?


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>