DatePicker Blackout Marks the Future and Some Past

I have a WPF application that requires a date of birth using DatePicker. I would like to turn off the dates of tomorrow and the rest of the time in addition to, say, 134 years ago and all that comes next. I tried to accomplish this with BlackoutDates, because we still want to allow manual input, but I was unsuccessful. Is there an easy way to do this?

+1
source share
2 answers

Thank you very much for your quick reply. I really managed to figure this out using DateTime.MaxValue and DateTime.MinValue and having two CalendarDateRanges in DatePicker.BlackoutDates tags. Sometimes you just need to ask a question to think about it differently :) Thanks again to the guys. Here is my xaml:

<DatePicker> <DatePicker.BlackoutDates> <CalendarDateRange Start="{x:Static app:CustomDateControl.FutureMinBlackoutDate}" End="{x:Static app:CustomDateControl.FutureMaxBlackoutDate}" /> <CalendarDateRange Start="{x:Static app:CustomDateControl.PastMinBlackoutDate}" End="{x:Static app:CustomDateControl.PastMaxBlackoutDate}" /> </DatePicker.BlackoutDates> </DatePicker> 
+2
source

You must also select a range for the dumper itself. if you're used to it, so nothing will be paid off. I think they are aware of this flaw, but for now, you need to give your pick date a start date as well as the cut-off dates. Any other date from the datepicker range will not be displayed at all. I think you'd better do this instead of darkening the dates.

0
source

Source: https://habr.com/ru/post/1338217/


All Articles