This documentation is archived and is not being maintained.

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)

property CalendarBlackoutDatesCollection^ BlackoutDates {
	CalendarBlackoutDatesCollection^ get ();

XAML Values


One or more object elements of type CalendarDateRange.

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.

The following example creates a DatePicker that displays the dates in August 2009 and specifies that each Saturday and Sunday is not selectable.

No code example is currently available or this language may not be supported.

<DatePicker Name="datePickerWithBlackoutDates"
    <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"/>

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.

No code example is currently available or this language may not be supported.

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

Supported in: 4

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.