Version

Using xamCalendar

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:

Introduction

The xamCalendar™ control provides functionality similar to that of the Microsoft Vista Common Controls Calendar class.

xamCalender Using 1.png

Figure 1: Example implementation of the xamCalendar control

Display Modes

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

Selection Modes

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.

Display Properties of the xamCalendar Control

Visibility Properties

The following properties control the visibility of different UI elements:

Layout Properties

  • 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).

Look-and-Feel Properties

The properties below control the look of the calendar. Except for the first one, ResourceProvider, they are all style-type properties:

Code Example

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;
...