Calendar Basics

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:

Silverlight RadCalendar Display Modes

<telerik:RadCalendar DisplayMode="YearView" x:Name="calendar"/> 

The navigation between different DisplayModes depends on the currently set DisplayDate. If, for example in the MonthView, the currently shown Month is August, but the SelectedDate is in September, clicking on the header button will navigate to YearView and will highlight August button.

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:

calendar.SelectedDate = DateTime.Today.AddDays(1); 
The SelectedDates property is a collection of all the selected dates in the Calendar. Note that it is read-only and cannot be bound in XAML - you can only add Dates to it with code.

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 Constraining Selection and Visible Days topic for more information on the managing the constraints.

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

//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); 
} 

Week Settings

You can use the following properties to configure the weeks inside RadCalendar:

  • FirstDayOfWeek - sets the first day of the week, if not set, depends on the default thread Culture.

  • CalendarWeekRule - sets the rule which determines the first calendar week of the year. It can receive the following values: FirstDay, FirstFourDayWeek, FirstFullWeek.

    For more details on the CalendarWeekRule settings see CalendarWeekRule Enumeration MSDN topic.

DatePicker

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

See Also

In this article