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

DatePicker SelectedDateChanged Event Firing Twice

$
0
0

Hello everyone,

My application loads data based on date, so when the window loads, I set the value of my DatePicker to today's date. Unfortunately, this seems to fire the SelectedDateChanged event twice, making the data load twice unnecessarily. When the date on the DatePicker is changed in any way (button click or typing in the date and pressing Enter) EXCEPT using the DatePicker's calendar, the SelectedDateChanged event is fired twice.

I found this forum post and tried out the solution, but unfortunately it is lacking. It relies on removing and adding the SelectedDateChanged event handler to the DatePicker after certain actions have taken place. Also, it fails to take into account the fact that the date can be changed by typing in a date on the DatePicker and pressing Enter. Finally, the solution isn't full-proof, as I have tried opening the calendar, closing it without changing the date, and clicking on a button. This caused the SelectedDateChanged event to fire twice when it shouldn't if using a real solution.

I'm wondering if anyone had any insight on how to make the SelectedDateChanged event fire ONLY once regardless of how the date on the DatePicker is changed. I would like the data on my application to load as fast as possible, and this is certainly slowing it down a lot.

Thanks in advance for any help!


Viewing all articles
Browse latest Browse all 18858

Trending Articles



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