RadControls for WPF

RadCalendar is a control that displays a calendar representation from which the user can select a single date or a range of dates (single, multiple and extended selection) with full keyboard support.

Display Modes

There are four Calendar modes that specify what is visible in the Calendar views : a month, a year, a decade or a century. The calendar modes can be switched by clicking the calendar header button. Or setting the DisplayMode property:

 

CopyXAML
<telerik:RadCalendar DisplayMode="YearView" />

Selection

The SelectedDate property holds the selected date, null means that no date is selected. The following code will select tomorrow's date in a calendar:

CopyC#
calendar.SelectedDate = DateTime.Today.AddDays(1);

The SelectedDates property is an observable collection of all the selected dates. Although it is exposed as a list, you can bind it and cast it to an observable collection if you need. Note that the SelectedDates property in the case of a Single selection mode will also contain the currently selected date, but it will be read-only.

If you add dates in the Selected dates collection, they should be valid with regard to the constraints of the calendar: selectable and display dates range. See the programming section for more information on the managing the constraints.

The following example selects all the work days (Monday to Friday) of the current month:

CopyXAML
//Make sure that more than one date can be selected:
calendar.SelectionMode = SelectionMode.Extended;
//Which month is it today?
int thisMonthIndex = DateTime.Today.Month;
DateTime dayOfMonth = new DateTime(DateTime.Today.Year, thisMonthIndex, 1);
while (thisMonthIndex == dayOfMonth.Month)
{
    //Add the date if is a Mon - Fri week day:
    if (dayOfMonth.DayOfWeek != DayOfWeek.Sunday && dayOfMonth.DayOfWeek != DayOfWeek.Saturday)
    {
        calendar.SelectedDates.Add(dayOfMonth);
    }
    dayOfMonth = dayOfMonth.AddDays(1);
}

For more information on the handling the selection events, see the Programming section.

DatePicker

If you need a calendar that takes less space, use the RadDatePicker control which in its essence is a DropDown with a calendar and date parser.

Styling and Appearance

The calendar control has over 30 properties that can be used to style almost any aspect of the control, for more information see the Styling and Appearance section.