DatePicker停电日期所有将来和过去的日期

DatePicker停电日期所有将来和过去的日期

问题描述:

我有一个WPF应用程序,其中需要使用DatePicker生日。除了134年前,我想取消明天的日期和其余时间。我尝试使用BlackoutDates完成此操作,因为我们仍然希望允许手动用户输入,但是我一直没有成功。

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 everything beyond that. I've tried accomplishing this with BlackoutDates because we still want to allow for manual user input, but I've been unsuccessful. Is there an easy way to accomplish this?

非常感谢你们两个人的快速回复。实际上,我可以使用DateTime.MaxValue和DateTime.MinValue并在DatePicker.BlackoutDates标签中具有两个CalendarDateRanges来解决此问题。有时您只需要发布一个问题即可以不同的方式考虑它:)再次感谢大家。这是我的xaml:

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>