WPF DatePicker control Reset
-
16 สิงหาคม 2555 2:21
Here is my situation.
I have a list of Items which have name, and date (DOB) properties associated them. I am displaying them on screen where the user can click on the name and I will display the DOB in a datepicker control.
1. The datepicker displays today's date as I am setting the DisplayDate to DateTime.Today.
2. The use changes the date to lets say 08/10/2020 by navigating through the datepicker's calendar control (the textbox is disabled on my screen) - the user clicks on August 2012 -> clicks on 2012 -> Cliks 2020 -> Clicks August -> selects date 10
3. User clicks on the next customer name.
4. I reset the displaydate to todays date.
5. the user Clicks on the calendar button to change the date. the Datepicker calendar displays August 2012 month. The user want to change the date to 05/03/2017. The user clicks on August 2012 . This time I am expecting that it will display year 2012 with all months in it. Instead it is displaying year 2020 (from the previous selection).
Is there a way to reset the datepicker control completely ?
ตอบทั้งหมด
-
16 สิงหาคม 2555 7:40
Hi,
you can set
IsTodayHighlighted property to true in xaml and when resetting in 4th step you must set selecteddate also to todays date, i have tried this it's working :)
Thanks & Regards dhampall
-
16 สิงหาคม 2555 14:56
Thanks for your Reply,
That didn't work for me though. To give more details
Here is my snippet of the xaml code
<datepickercontrol Name="datePickerToDate" DisplayDate="{Binding Path=DisplayDateValue, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" DataContext="{Binding}"
SelectedDate="{Binding Path=SelectedDateValue, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" DisplayDateStart="{Binding Path=DateStart}">
</datepickercontrol>
DisplayDate and SelectedDateValue are defined in the the viewmodel.
I can not set the selected date to today's date as I want to set to null if there is no value.
I will set the display date to today's date if there is no SelecteDate otherwise it will default to the SelectedDate