Calendar.SelectionMode Property
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Gets or sets a value that indicates what kind of selections are allowed.
Namespace: System.Windows.Controls
Assembly: System.Windows.Controls (in System.Windows.Controls.dll)
Syntax
'Declaration
Public Property SelectionMode As CalendarSelectionMode
public CalendarSelectionMode SelectionMode { get; set; }
<sdk:Calendar SelectionMode="selectionModeValue"/>
XAML Values
- selectionModeValue
A named constant of the CalendarSelectionMode enumeration, such as SingleDate.
Property Value
Type: System.Windows.Controls.CalendarSelectionMode
A value that indicates the current selection mode. The default is SingleDate.
Remarks
Dependency property identifier field: SelectionModeProperty
This property determines whether the Calendar allows no selection, selection of a single date, or selection of multiple dates. The selection mode is specified with the CalendarSelectionMode enumeration.
When this property is changed, all selected dates will be cleared.
Examples
The following code provides an example of configuring a Calendar so that multiple ranges of dates can 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))
//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));
Version Information
Silverlight
Supported in: 5, 4, 3
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.