DatePicker BlackoutDates all future and some past

后端 未结 2 416
失恋的感觉
失恋的感觉 2021-01-23 17:54

I have a WPF application where a birthdate is required using DatePicker. I\'d like to blackout dates of tomorrow and the rest of time in addition to, say 134 years ago and every

相关标签:
2条回答
  • 2021-01-23 18:29

    Thanks so much for both of you quickly replying. I was actually able to figure this out using DateTime.MaxValue and DateTime.MinValue and having two CalendarDateRanges in my DatePicker.BlackoutDates tags. Sometimes you just need to post a question to think about it in a different way :) Thanks again guys. Here's 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>
    
    0 讨论(0)
  • 2021-01-23 18:36

    You have to choose range for the datepicker itself, too. if you wont, so nothing will be blacked out. I think they know about this lack feature, but currently you need to give your date picker a Start date same as your blackout dates. Every other date out of the datepicker's range won't be shown at all. I think it is better for you to do that instead of blacking out dates.

    0 讨论(0)
提交回复
热议问题