DatePicker.BlackoutDates Property


Gets or sets a collection of dates that are marked as not selectable.

Namespace:   System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

public CalendarBlackoutDatesCollection BlackoutDates { 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.



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.

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

DatePicker with dates that are not selectable

.NET Framework
Available since 4.0
Available since 2.0
Return to top
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft