DatePicker停电日期所有将来和过去的日期 [英] DatePicker BlackoutDates all future and some past

查看:81
本文介绍了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>

这篇关于DatePicker停电日期所有将来和过去的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆