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

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

问题描述

我正在使用DatePicker的控件,我试图限制日期显示MinDate& Maxdate。不幸的是,我找不到任何相关的方法来设置除了Year之外的Min和Max日/月,我甚至试图扩展Controls类,以便在DatePicker加载期间设置要显示的Date。可以限制用户可以从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平台上开发。 DatePicker在UWP中,您只能设置MinYear和MaxYear。您可以使用4个datetime控件(请参阅此链接< a>)

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);

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

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