Calendar missing StartDate and EndDate

Nov 20, 2008 at 9:03 AM
Edited Nov 20, 2008 at 10:12 AM
Wouldn't it very convenient with an end date and start  date at the calendar?

Thereby dates not displayed also are 'Blackoutdates' instead of
Calendar.BlackoutDates.Add(new CalendarDateRange(DateTime.Now, DateTime.MaxValue);
for giving the Calendar an expiration date.
It could be a convenience method at CalendarBlackoutDatesCollection::DatesBefore and CalendarBlackoutDatesCollection::DatesAfter like the CalendarBlackoutDatesCollection::AddDatesInPast.
Nov 20, 2008 at 9:28 PM
If I understand your qualm correctly, you are confused about why we have Blackoutdates as well as DisplayDateStart and DisplayDateEnd.
One rationale for this is that DisplayDates can coerce to fit a SelectedDate outside of the initial display range and that Blackoutdates are dates that cannot be chosen. They serve different purposes... one superficially limits browsing, the other explicity prevents particular dates from being selected. If one really wanted to prevent the dates outside the initial display range from being selected they can blackout those dates fairly easily. This design decision was also required to maintain parity with our Silverlight control which came first. As for your you convenience method suggestions, those were considered and are good suggestions, but we opted to keep the API smaller and let the developer handle these simpler scenarios.

-Eric Fabricant, MSFT
Jul 1, 2010 at 4:58 AM

Hi Eric,

I'm trying to come to grips with the way SelectedDateStart and SelectedDateEnd work, and how I might constrain the dates inside a DatePicker.

How would I constrain the DatePicker such that the user cannot enter a date before today or after one week from now? Setting SelectedDateStart and SelectedDateEnd obviously don't stop the user from typing a date outside of that range. Do I really have to add every single day (from DateTime.MinValue to DateTime.MaxValue) other than the seven valid dates to the BlackoutDates collection? I'm amazed that there's no "Minimum" and "Maximum" (or even "MinDate" and "MaxDate") properties like there were on the Windows Forms DateTimePicker control.