DatePicker::BlackoutDates Property
Gets or sets a collection of dates that are marked as not selectable.
Assembly: PresentationFramework (in PresentationFramework.dll)
public: property CalendarBlackoutDatesCollection^ BlackoutDates { CalendarBlackoutDatesCollection^ get(); }
Property Value
Type: System.Windows.Controls::CalendarBlackoutDatesCollection^A collection of dates that cannot be selected. The default value is an empty collection.
Dates in this collection will appear as disabled on the drop-down calendar. If the user types a date that is not selectable, the DateValidationError event occurs.
To make all past dates not selectable, you can use the AddDatesInPast method provided by the collection returned by this property.
Adding a date to this collection when it is already selected or adding a date outside the range specified by DisplayDateStart and DisplayDateEnd will cause an ArgumentOutOfRangeException.
<object>
<object.BlackoutDates>
oneOrMoreCalendarDateRanges
</object.BlackoutDates>
</object>
- oneOrMoreCalendarDateRanges
One or more object elements of type CalendarDateRange.
The following example creates a DatePicker that displays the dates in August 2009 and specifies that each Saturday and Sunday is not selectable.
<DatePicker Name="datePickerWithBlackoutDates" DisplayDateStart="8/1/09" DisplayDateEnd="8/31/09" SelectedDate="8/10/09" DateValidationError="DatePicker_DateValidationError"> <DatePicker.BlackoutDates> <CalendarDateRange Start="8/1/09" End="8/2/09"/> <CalendarDateRange Start="8/8/09" End="8/9/09"/> <CalendarDateRange Start="8/15/09" End="8/16/09"/> <CalendarDateRange Start="8/22/09" End="8/23/09"/> <CalendarDateRange Start="8/29/09" End="8/30/09"/> </DatePicker.BlackoutDates> </DatePicker>
The DatePicker handles the DateValidationError event, as shown in the following code. If the user enters a date that is not selectable, the example displays a message. If the user enters text that is not a valid date, an exception is thrown.
The preceding example produces output that is similar to the following illustration.

DatePicker with dates that are not selectable
Available since 4.0
Silverlight
Available since 2.0