Calendar

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.

Task Implementation
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 Combination DisplayMode Action
ARROW Month Changes the SelectedDate property if the SelectionMode property is not set to None.
ARROW Year Changes the month of the DisplayDate property. Note that the SelectedDate does not change.
ARROW Decade Changes the year of the DisplayDate. Note that the SelectedDate does not change.
SHIFT+ARROW Month If SelectionMode is not set to SingleDate or None, extends the range of selected dates.
HOME Month Changes the SelectedDate to the first day of the current month.
HOME Year Changes the month of the DisplayDate to the first month of the year. The SelectedDate does not change.
HOME Decade Changes the year of the DisplayDate to the first year of the decade. The SelectedDate does not change.
END Month Changes the SelectedDate to the last day of the current month.
END Year Changes the month of the DisplayDate to the last month of the year. The SelectedDate does not change.
END Decade Changes the year of the DisplayDate to the last year of the decade. The SelectedDate does not change.
CTRL+UP ARROW Any Switches to the next larger DisplayMode. If DisplayMode is already Decade, no action.
CTRL+DOWN ARROW Any Switches to the next smaller DisplayMode. If DisplayMode is already Month, no action.
SPACEBAR or ENTER Year or Decade Switches DisplayMode to the Month or Year represented by focused item.

See also