The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Calendar.BlackoutDates Property

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

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

public CalendarBlackoutDatesCollection BlackoutDates { get; private set; }

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 calendar.

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 result in an ArgumentOutOfRangeException.

The following code provides an example of configuring a Calendar so that some dates cannot be selected. This example is part of a larger example available in the Calendar overview.

//Sets a Calendar to allow multiple selections, and configures
//some dates to be unselectable.
cal3.SelectionMode = CalendarSelectionMode.MultipleRange;
cal3.DisplayDate = new DateTime(2009, 1, 1);
cal3.DisplayDateStart = new DateTime(2009, 1, 1);
cal3.DisplayDateEnd = new DateTime(2009, 1, 31);
cal3.BlackoutDates.Add(new CalendarDateRange(new DateTime(2009, 1, 2), new DateTime(2009, 1, 4)));
cal3.BlackoutDates.Add(new CalendarDateRange(new DateTime(2009, 1, 9)));
cal3.BlackoutDates.Add(new CalendarDateRange(new DateTime(2009, 1, 16)));
cal3.BlackoutDates.Add(new CalendarDateRange(new DateTime(2009, 1, 23), new DateTime(2009, 1, 25)));
cal3.BlackoutDates.Add(new CalendarDateRange(new DateTime(2009, 1, 30)));

cal3.SelectedDates.Add(new DateTime(2009, 1, 5));
cal3.SelectedDates.AddRange(new DateTime(2009, 1, 12), new DateTime(2009, 1, 15));
cal3.SelectedDates.Add(new DateTime(2009, 1, 27));


Supported in: 5, 4, 3

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft