Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Mindate and MaxDate for Datepicker Control

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?

Thanks!

like image 863
Osirus Avatar asked Dec 04 '22 02:12

Osirus


1 Answers

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)

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);
like image 144
mraswinc Avatar answered Jan 11 '23 15:01

mraswinc