为 Datepicker 控件设置 Mindate 和 MaxDate [英] Setting Mindate and MaxDate for Datepicker Control

查看:62
本文介绍了为 Datepicker 控件设置 Mindate 和 MaxDate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用 DatePicker 的控件,我试图限制日期以显示 MinDate &最大日期.不幸的是,我找不到任何相关的方法来设置除年之外的最小和最大天数/月,我什至尝试扩展 Controls 类以设置要在 DatePicker 加载期间显示的日期.是否可以限制用户可以从 UWP 应用程序的日期选择器中选择哪些日期?

I'm currently using DatePicker’s control, where I tried to limit the dates to show MinDate & Maxdate. Unfortunately I couldn't find any related method to set the Min and Max days/Month except for Year, I even tried to extends the Controls class to set the Date to be display during it the DatePicker loaded. Is it possible to limit which dates a user can select from a datepicker on a UWP application?

谢谢!

推荐答案

我假设您在 Windows 10 通用 Windows 平台上进行开发.UWP 中的DatePicker,只能设置MinYear 和MaxYear.您可以使用 4 个日期时间控件(请参阅此链接)

I assume you're developing on Windows 10 Universal Windows Platform. DatePicker in UWP, you can only set the MinYear and MaxYear. There's 4 datetime control that you can use (Refer to this link)

我建议您使用新的 日历日期选择器 允许您设置 MinDate 和 MaxDate

I would suggest you to use the new Calendar Date Picker which allows you to set MinDate and MaxDate

CalendarDatePicker cdp=new CalendarDatePicker();
cdp.MinYear=DateTime.Now();
cdp.MaxYear=DateTime.AddYears(3);

这篇关于为 Datepicker 控件设置 Mindate 和 MaxDate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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