This topic explains the xamCalendar control and its modes and properties. At the end, example code is provided demonstrating how to use the main properties of the control to customize its appearance and functionalities.
The topic is organized as follows:
The xamCalendar™ control provides functionality similar to that of the Microsoft Vista Common Controls Calendar class.
Figure 1: Example implementation of the xamCalendar control
The control provides navigation functionality enabling you to zoom in/out for a faster navigation and ease of changing the selection. There are two properties for controlling the zoom modes:
CurrentMode – controls the current display mode (Day, Month, Year, Decade or Century)
MinCalendarMode – controls the lowest zoom level to which the user can navigate
The control supports Single and Multiple selection modes. They are managed from its SelectionMode property. When using a Multiple selection mode such as Extended or Range, use the SelectedDates property to access/change the selection. The control also has a SelectedDate property which is primarily used when in a Single selection mode. When in a Multiple selection mode, this property returns the first selected date.
The following properties control the visibility of different UI elements:
LeadingAndTrailingDatesVisibility – configures the visibility of the dates that don’t belong to the current month (applicable when CurrentMode is set to Days)
WeekNumberVisibility – controls the visibility of the week numbers (calculated by setting the WeekRule property)
TodayButtonVisibility – configures the visibility of the TodayButton
DayOfWeekHeaderVisibility – configures the visibility of the calendar day of week headers (the display format is controlled by the DayOfWeekHeaderFormat property)
Dimensions - controls how many CalendarItemGroup instances are shown, based on the row/column count (in Figure 1 above, the Dimensions property is set to 1 row x 2 columns).
AutoAdjustDimensions - configures the control to automatically fill the available space in the panel with additional CalendarItemGroups.
ScrollDirection - configures the scrolling direction of the CalendarItemGroup instance(s).
The properties below control the look of the calendar. Except for the first one, ResourceProvider, they are all style-type properties:
CalendarDayStyle – CalendarDay is the element that represents an individual day (used only when the CurrentMode of the control is set to Days)
CalendarItemStyle – CalendarItem is the element that represents range of dates (used only when the CurrentMode of the control is set to anything other than Days)
ScrollNextRepeatButtonStyle and ScrollPreviousRepeatButtonStyle – control the style of the two RepeatButtons used to scroll forward and backward thru the CalendarDays or CalendarItems
TodayButtonStyle – controls the style of the button that selects and navigates to the current date
The following example code demonstrates the settings for the xamCalendar control shown in Figure 1 above.
In XAML:
<ig:XamCalendar x:Name="myCalendar" DayOfWeekHeaderFormat="Abbreviated" CurrentMode="Days" Dimensions="1,2" FirstDayOfWeek="Monday" AutoAdjustDimensions=" DayOfWeekHeaderVisibility="Visible" MinCalendarMode="Days" SelectionMode="Extended" TodayButtonVisibility="Visible" WeekNumberVisibility="Visible" LeadingAndTrailingDatesVisibility="Visible" WeekRule="FirstFullWeek"/>
In Visual Basic:
Imports Infragistics.Controls.Editors ... Dim myCalendar = New XamCalendar() myCalendar.Name = "myCalendar" myCalendar.DayOfWeekHeaderFormat = DayOfWeekHeaderFormat.Abbreviated myCalendar.CurrentMode = CalendarZoomMode.Days myCalendar.Dimensions = New Infragistics.Controls.Editors.Primitives.CalendarDimensions(1, 2) myCalendar.FirstDayOfWeek = System.DayOfWeek.Monday myCalendar.AutoAdjustDimensions = False myCalendar.DayOfWeekHeaderVisibility = Visibility.Visible myCalendar.MinCalendarMode = CalendarZoomMode.Days myCalendar.SelectionMode = CalendarDateSelectionMode.Extended myCalendar.TodayButtonVisibility = Visibility.Visible myCalendar.WeekNumberVisibility = Visibility.Visible myCalendar.LeadingAndTrailingDatesVisibility = Visibility.Visible myCalendar.WeekRule = System.Globalization.CalendarWeekRule.FirstFullWeek ...
In C#:
using Infragistics.Controls.Editors; ... var myCalendar = new XamCalendar(); myCalendar.Name = "myCalendar"; myCalendar.DayOfWeekHeaderFormat = DayOfWeekHeaderFormat.Abbreviated; myCalendar.CurrentMode = CalendarZoomMode.Days; myCalendar.Dimensions = new Infragistics.Controls.Editors.Primitives.CalendarDimensions(1, 2); myCalendar.FirstDayOfWeek = System.DayOfWeek.Monday; myCalendar.AutoAdjustDimensions = false; myCalendar.DayOfWeekHeaderVisibility = Visibility.Visible; myCalendar.MinCalendarMode = CalendarZoomMode.Days; myCalendar.SelectionMode = CalendarDateSelectionMode.Extended; myCalendar.TodayButtonVisibility = Visibility.Visible; myCalendar.WeekNumberVisibility = Visibility.Visible; myCalendar.LeadingAndTrailingDatesVisibility = Visibility.Visible; myCalendar.WeekRule = System.Globalization.CalendarWeekRule.FirstFullWeek; ...