Calendar

.NET Framework (current version)
 

A calendar enables a user to select a date by using a visual calendar display.

A Calendar control can be used on its own, or as a drop-down part of a DatePicker control. For more information, see DatePicker.

The following illustration shows two Calendar controls, one with selections and blackout dates and one without.

Calendar controls
Calendar controls

The following table provides information about tasks that are typically associated with the Calendar.

TaskImplementation
Specify dates that cannot be selected.Use the BlackoutDates property.
Have the Calendar display a month, an entire year, or a decade.Set the DisplayMode property to Month, Year, or Decade.
Specify whether the user can select a date, a range of dates, or multiple ranges of dates.Use the SelectionMode.
Specify the range of dates that the Calendar displays.Use the DisplayDateStart and DisplayDateEnd properties.
Specify whether the current date is highlighted.Use the IsTodayHighlighted property. By default, IsTodayHighlighted is true.
Change the size of the Calendar.Use a Viewbox or set the LayoutTransform property to a ScaleTransform. Note that if you set the Width and Height properties of a Calendar, the actual calendar does not change its size.

The Calendar control provides basic navigation using either the mouse or keyboard. The following table summarizes keyboard navigation.

Key CombinationDisplayModeAction
ARROWMonthChanges the SelectedDate property if the SelectionMode property is not set to None.
ARROWYearChanges the month of the DisplayDate property. Note that the SelectedDate does not change.
ARROWDecadeChanges the year of the DisplayDate. Note that the SelectedDate does not change.
SHIFT+ARROWMonthIf SelectionMode is not set to SingleDate or None, extends the range of selected dates.
HOMEMonthChanges the SelectedDate to the first day of the current month.
HOMEYearChanges the month of the DisplayDate to the first month of the year. The SelectedDate does not change.
HOMEDecadeChanges the year of the DisplayDate to the first year of the decade. The SelectedDate does not change.
ENDMonthChanges the SelectedDate to the last day of the current month.
ENDYearChanges the month of the DisplayDate to the last month of the year. The SelectedDate does not change.
ENDDecadeChanges the year of the DisplayDate to the last year of the decade. The SelectedDate does not change.
CTRL+UP ARROWAnySwitches to the next larger DisplayMode. If DisplayMode is already Decade, no action.
CTRL+DOWN ARROWAnySwitches to the next smaller DisplayMode. If DisplayMode is already Month, no action.
SPACEBAR or ENTERYear or DecadeSwitches DisplayMode to the Month or Year represented by focused item.

Controls
Styling and Templating

Show: