Version

XamMonthCalendar Class

A custom control used to display one or more months.
Syntax
Remarks

The XamMonthCalendar provides functionality similar to that of the Microsoft Vista Common Controls MonthCalendar class.

The control provides navigation style functionality whereby you can zoom out to more quickly navigate the available dates and then zoom back into to change the selection. The CurrentCalendarMode is used to control the current mode. The MinCalendarMode may be used to control the lowest level of dates that the end user may navigate into.

The default template for XamMonthCalendar uses a CalendarItemGroupPanel that will generate CalendarItemGroup instances based on the row/column count specified via the CalendarDimensions. In addition, when the AutoAdjustCalendarDimensions property is set to true, which is the default value, the panel will automatically generate additional groups to fill the available space up to its CalendarItemGroupPanel.MaxGroups. The ReferenceDate is used by the groups to determine which dates should be shown.

The control supports multiple selection modes which can be controlled via its SelectionType. When using a multiple selection mode such as Extended or Range, the SelectedDates property may be used to access/change the selection up to the MaxSelectedDates. The control also exposes a SelectedDate property which is primarily used when in a single select mode. When in a multiselect mode, this property will return the first selected date.

The control exposes a number of properties that may be used to restrict the selectable dates. The MinDate and MaxDate are used to control the range within which the user may navigate. You can then disable dates within that range using either the DisabledDaysOfWeek and DisabledDates.

Example
This sample demonstrates how to create and initialize a new XamMonthCalendar.

Imports Infragistics.Windows.Editors
Imports Infragistics.Windows.Controls

    Private Sub InitializeCalendar(ByVal calendar As XamMonthCalendar)
        ' by default the template of the xammonthcalendar uses a calendaritemgrouppanel
        ' which will automatically create groups as needed based on the available size
        ' to use a fixed size, you can set AutoAdjustCalendarDimensions to false and 
        ' set the CalendarDimensions to the dimensions you want it to always use
        calendar.AutoAdjustCalendarDimensions = False
        calendar.CalendarDimensions = New CalendarDimensions(2, 2)

        ' DisabledDaysOfWeek is a flagged enumeration of the days of the week
        ' that should be disabled and therefore disallow activation and selection
        calendar.DisabledDaysOfWeek = DayOfWeekFlags.Saturday Or DayOfWeekFlags.Sunday

        ' the default selection type allows for selection of multiple dates
        calendar.SelectionType = SelectionType.Single

        ' the min/max dates control the range of dates that are available
        ' for activation/selection. any dates outside this range will not
        ' be shown
        calendar.MinDate = New DateTime(2008, 1, 1)
        calendar.MaxDate = New DateTime(2099, 12, 31)

        ' by default week numbers are not displayed
        calendar.WeekNumberVisibility = Visibility.Visible

        ' the today button that is used to select the current date
        ' can be removed using the TodayButtonVisibility
        calendar.TodayButtonVisibility = Visibility.Collapsed

        ' by default leading and trailing dates (e.g. days before
        ' and after the first/last visible month) are displayed
        ' within the control
        calendar.ShowLeadingAndTrailingDates = False
    End Sub
using Infragistics.Windows.Editors;
using Infragistics.Windows.Controls;

        private void InitializeCalendar(XamMonthCalendar calendar)
        {
            // by default the template of the xammonthcalendar uses a calendaritemgrouppanel
            // which will automatically create groups as needed based on the available size
            // to use a fixed size, you can set AutoAdjustCalendarDimensions to false and 
            // set the CalendarDimensions to the dimensions you want it to always use
            calendar.AutoAdjustCalendarDimensions = false;
            calendar.CalendarDimensions = new CalendarDimensions(2, 2);

            // DisabledDaysOfWeek is a flagged enumeration of the days of the week
            // that should be disabled and therefore disallow activation and selection
            calendar.DisabledDaysOfWeek = DayOfWeekFlags.Saturday | DayOfWeekFlags.Sunday;

            // the default selection type allows for selection of multiple dates
            calendar.SelectionType = SelectionType.Single;

            // the min/max dates control the range of dates that are available
            // for activation/selection. any dates outside this range will not
            // be shown
            calendar.MinDate = new DateTime(2008, 1, 1);
            calendar.MaxDate = new DateTime(2099, 12, 31);

            // by default week numbers are not displayed
            calendar.WeekNumberVisibility = Visibility.Visible;

            // the today button that is used to select the current date
            // can be removed using the TodayButtonVisibility
            calendar.TodayButtonVisibility = Visibility.Collapsed;

            // by default leading and trailing dates (e.g. days before
            // and after the first/last visible month) are displayed
            // within the control
            calendar.ShowLeadingAndTrailingDates = false;
        }
<UserControl x:Class="Xaml.UserControl1"
    
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    
xmlns:igEditors="http://infragistics.com/Editors"
    
xmlns:igThemes="http://infragistics.com/Themes">
    
<igEditors:XamMonthCalendar
        
x:Name="xamMonthCalendar1"
        
AutoAdjustCalendarDimensions="False"
        
CalendarDimensions="2,2"
        
DisabledDaysOfWeek="Saturday, Sunday"
        
SelectionType="Single"
        
MinDate="1/1/2000"
        
MaxDate="12/31/2099"
        
WeekNumberVisibility="Visible"
        
TodayButtonVisibility="Collapsed"
        
ShowLeadingAndTrailingDates="False" />
</UserControl>
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also