MonthCalendar Class
Represents a month calendar control.
public class MonthCalendar : Control
- Inheritance:
- object Visual UIElement FrameworkElement Control object
Constructors
MonthCalendar()
Initializes an instance of the class.
public MonthCalendar()
Properties
ActiveDate
The active date in the calendar.
ActiveViewMode
The active view mode of the calendar.
public MonthCalendarViewMode ActiveViewMode { get; set; }
Property Value
- MonthCalendarViewMode:
The default value is Month.
CalendarWeekRule
The calendar week rule, which determines how weeks are numbered.
public CalendarWeekRule? CalendarWeekRule { get; set; }
Property Value
- CalendarWeekRule?:
When set to
null, the calendar week rule is pulled from the current culture. The default value isnull.
CanRetainTime
Indicates whether the various DateTime values can retain the time-portion, or if it is reset to midnight.
public bool CanRetainTime { get; set; }
Property Value
ClearButtonStyle
The Style to apply to the Clear button.
ClearButtonText
The text to display in the Clear button.
ClearSelectionCommand
The ICommand that is used to clear the selection.
DayItemTemplate
The DataTemplate to use for day items.
DayItemTemplateSelector
The DataTemplateSelector to use for day items.
public DataTemplateSelector? DayItemTemplateSelector { get; set; }
Property Value
DayItemsPanelTemplate
The ItemsPanelTemplate to use for arranging day items.
DayNameItemContainerStyle
The Style to apply to day name items.
DayNameItemTemplate
The DataTemplate to use for day name items.
DayNameItemsPanelTemplate
The ItemsPanelTemplate to use for arranging day name items.
public ItemsPanelTemplate? DayNameItemsPanelTemplate { get; set; }
Property Value
DayOfWeekFormatPattern
The format pattern used for DayOfWeek values.
public DayOfWeekFormatPattern DayOfWeekFormatPattern { get; set; }
Property Value
- DayOfWeekFormatPattern:
The default value is AbbreviatedUppercase.
DecadeItemTemplate
The DataTemplate to use for decade items.
DecadeItemsPanelTemplate
The ItemsPanelTemplate to use for arranging decade items.
DisabledDaysOfWeek
The disabled days of the week.
public DaysOfWeek DisabledDaysOfWeek { get; set; }
Property Value
- DaysOfWeek:
The default value is None.
FirstDayOfWeek
The first day of the week.
public DayOfWeek? FirstDayOfWeek { get; set; }
Property Value
- DayOfWeek?:
When set to
null, the first day of the week is pulled from the current culture. The default value isnull.
GoToNextViewCommand
The ICommand that is used to go to the next view.
GoToPreviousViewCommand
The ICommand that is used to go to the next view.
IsClearButtonVisible
Indicates whether the clear button is visible.
public bool IsClearButtonVisible { get; set; }
Property Value
- bool:
trueif the clear button is visible; otherwisefalse. The default value isfalse.
IsDateDisabledFunc
A function that is called when a day cell is rendered to determine if it should be disabled.
public Func<DateTime, bool>? IsDateDisabledFunc { get; set; }
Property Value
Remarks
This function is not called for dates that are outside of the Minimum and Maximum range, nor for dates that are disabled by the DisabledDaysOfWeek property.
IsDayOfWeekSelectionEnabled
Indicates whether the day of week headers can be used to select dates.
public bool IsDayOfWeekSelectionEnabled { get; set; }
Property Value
- bool:
trueif the day of week headers can be used to select dates; otherwisefalse. The default value istrue.
IsTodayButtonVisible
Indicates whether the Today button is visible.
public bool IsTodayButtonVisible { get; set; }
Property Value
- bool:
trueif the Today button is visible; otherwisefalse. The default value istrue.
IsTodayHighlighted
Indicates whether DateTime.Today is highlighted.
public bool IsTodayHighlighted { get; set; }
Property Value
- bool:
trueifDateTime.Todayis highlighted; otherwisefalse. The default value istrue.
IsWeekNumberColumnVisible
Indicates whether the week number column is visible.
public bool IsWeekNumberColumnVisible { get; set; }
Property Value
- bool:
trueif the week number column is visible; otherwisefalse. The default value isfalse.
IsWeekNumberSelectionEnabled
Indicates whether the week numbers can be used to select dates.
public bool IsWeekNumberSelectionEnabled { get; set; }
Property Value
- bool:
trueif the week numbers can be used to select dates; otherwisefalse. The default value istrue.
MaxSelectionCount
The maximum number of dates that can be selected.
public int MaxSelectionCount { get; set; }
Property Value
- int:
The default value is
-1, which indicates no upper limit.
MaxViewMode
The maximum view mode allowed.
public MonthCalendarViewMode MaxViewMode { get; set; }
Property Value
- MonthCalendarViewMode:
The default value is Century.
See Also
Maximum
The highest possible value.
Minimum
The lowest possible value.
MonthItemTemplate
The DataTemplate to use for month items.
MonthItemsPanelTemplate
The ItemsPanelTemplate to use for arranging month items.
NavigationButtonStyle
The Style to apply to the navigation buttons.
SelectDateCommand
The ICommand that is used to select a date.
SelectDayOfWeekCommand
The ICommand that is used to select an entire day of week.
SelectTodayCommand
The ICommand that is used to select today's date.
public ICommand SelectTodayCommand { get; }
Property Value
Remarks
This command calls the SelectToday() method.
SelectWeekCommand
The ICommand that is used to select an entire week.
SelectedDate
The selected date, if any, in the calendar.
SelectedDates
The currently-selected dates in the calendar.
SelectionMode
The selection mode of the calendar.
public MonthCalendarSelectionMode SelectionMode { get; set; }
Property Value
- MonthCalendarSelectionMode:
The default value is Single.
Title
The title that is displayed for the active view.
TitleButtonStyle
The Style to apply to the title button.
TodayButtonStyle
The Style to apply to the Today button.
TodayButtonText
The text to display in the Today button.
ViewResetMode
The view reset mode, which can be used to reset the view when the calendar loses focus.
public MonthCalendarViewResetMode ViewResetMode { get; set; }
Property Value
- MonthCalendarViewResetMode:
The default value is None.
WeekNumberItemContainerStyle
The Style to apply to week number items.
WeekNumberItemTemplate
The DataTemplate to use for week number items.
WeekNumberItemsPanelTemplate
The ItemsPanelTemplate to use for arranging week number items.
public ItemsPanelTemplate? WeekNumberItemsPanelTemplate { get; set; }
Property Value
YearItemTemplate
The DataTemplate to use for year items.
YearItemsPanelTemplate
The ItemsPanelTemplate to use for arranging year items.
ZoomInCommand
The ICommand that is used to zoom in.
ZoomOutCommand
The ICommand that is used to zoom out.
Methods
OnApplyTemplate()
Invoked whenever application code or internal processes call ApplyTemplate.
public override void OnApplyTemplate()
OnCreateAutomationPeer()
Returns class-specific AutomationPeer implementations for the Windows Presentation Foundation (WPF) infrastructure.
protected override AutomationPeer OnCreateAutomationPeer()
Returns
- AutomationPeer:
The type-specific AutomationPeer implementation.
OnIsKeyboardFocusWithinChanged(DependencyPropertyChangedEventArgs)
Invoked just before the IsKeyboardFocusWithinChanged event is raised by this element. Implement this method to add class handling for this event.
protected override void OnIsKeyboardFocusWithinChanged(DependencyPropertyChangedEventArgs e)
| Parameter | Type | Description |
|---|---|---|
| e | DependencyPropertyChangedEventArgs | A System.Windows.DependencyPropertyChangedEventArgs that contains the event data. |
OnKeyDown(KeyEventArgs)
Invoked when an unhandled System.Windows.Input.Keyboard.KeyDown attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.
protected override void OnKeyDown(KeyEventArgs e)
| Parameter | Type | Description |
|---|---|---|
| e | KeyEventArgs | The KeyEventArgs that contains the event data. |
Refresh(bool)
Refreshes the control.
public void Refresh(bool requiresNewView)
| Parameter | Type | Description |
|---|---|---|
| requiresNewView | bool | Whether a new view is required (if UI elements are changing instead of only simple data). |
SelectToday()
Selects today's date.
public void SelectToday()
UpdateDayItem(MonthCalendarItem, DateTime)
Updates a MonthCalendarItem for the specified day.
protected virtual void UpdateDayItem(MonthCalendarItem item, DateTime date)
| Parameter | Type | Description |
|---|---|---|
| item | MonthCalendarItem | The MonthCalendarItem to update. |
| date | DateTime | The date for which to update the model. |
UpdateDayNameItem(MonthCalendarItem, DayOfWeek)
Updates a MonthCalendarItem for the specified day of week.
protected virtual void UpdateDayNameItem(MonthCalendarItem item, DayOfWeek dayOfWeek)
| Parameter | Type | Description |
|---|---|---|
| item | MonthCalendarItem | The MonthCalendarItem to update. |
| dayOfWeek | DayOfWeek | The updated day of week. |
UpdateDecadeItem(MonthCalendarItem, DateTime)
Updates a MonthCalendarItem for the specified decade.
protected virtual void UpdateDecadeItem(MonthCalendarItem item, DateTime date)
| Parameter | Type | Description |
|---|---|---|
| item | MonthCalendarItem | The MonthCalendarItem to update. |
| date | DateTime | The date for which to update the model. |
UpdateMonthItem(MonthCalendarItem, DateTime)
Updates a MonthCalendarItem for the specified month.
protected virtual void UpdateMonthItem(MonthCalendarItem item, DateTime date)
| Parameter | Type | Description |
|---|---|---|
| item | MonthCalendarItem | The MonthCalendarItem to update. |
| date | DateTime | The date for which to update the model. |
UpdateWeekNumberItem(MonthCalendarItem, int)
Updates a MonthCalendarItem for the specified week number.
protected virtual void UpdateWeekNumberItem(MonthCalendarItem item, int weekNumber)
| Parameter | Type | Description |
|---|---|---|
| item | MonthCalendarItem | The MonthCalendarItem to update. |
| weekNumber | int | The updated week number. |
UpdateYearItem(MonthCalendarItem, DateTime)
Updates a MonthCalendarItem for the specified year.
protected virtual void UpdateYearItem(MonthCalendarItem item, DateTime date)
| Parameter | Type | Description |
|---|---|---|
| item | MonthCalendarItem | The MonthCalendarItem to update. |
| date | DateTime | The date for which to update the model. |
Events
SelectionChanged
Occurs after the SelectedDate property value and/or SelectedDates collection changes.
SelectionCommitted
Occurs when the selection is committed, either by pressing Enter or clicking on a date value in single selection mode.
Fields
ActiveDateProperty
Defines the ActiveDate property.
public static readonly DependencyProperty ActiveDateProperty
ActiveViewModeProperty
Defines the ActiveViewMode property.
public static readonly DependencyProperty ActiveViewModeProperty
CalendarWeekRuleProperty
Defines the CalendarWeekRule property.
public static readonly DependencyProperty CalendarWeekRuleProperty
CanRetainTimeProperty
Defines the CanRetainTime property.
public static readonly DependencyProperty CanRetainTimeProperty
ClearButtonStyleProperty
Defines the ClearButtonStyle property.
public static readonly DependencyProperty ClearButtonStyleProperty
ClearButtonTextProperty
Defines the ClearButtonText property.
public static readonly DependencyProperty ClearButtonTextProperty
DayItemTemplateProperty
Defines the DayItemTemplate property.
public static readonly DependencyProperty DayItemTemplateProperty
DayItemTemplateSelectorProperty
Defines the DayItemTemplateSelector property.
public static readonly DependencyProperty DayItemTemplateSelectorProperty
DayItemsPanelTemplateProperty
Defines the DayItemsPanelTemplate property.
public static readonly DependencyProperty DayItemsPanelTemplateProperty
DayNameItemContainerStyleProperty
Defines the DayNameItemContainerStyle property.
public static readonly DependencyProperty DayNameItemContainerStyleProperty
DayNameItemTemplateProperty
Defines the DayNameItemTemplate property.
public static readonly DependencyProperty DayNameItemTemplateProperty
DayNameItemsPanelTemplateProperty
Defines the DayNameItemsPanelTemplate property.
public static readonly DependencyProperty DayNameItemsPanelTemplateProperty
DayOfWeekFormatPatternProperty
Defines the DayOfWeekFormatPattern property.
public static readonly DependencyProperty DayOfWeekFormatPatternProperty
DecadeItemTemplateProperty
Defines the DecadeItemTemplate property.
public static readonly DependencyProperty DecadeItemTemplateProperty
DecadeItemsPanelTemplateProperty
Defines the DecadeItemsPanelTemplate property.
public static readonly DependencyProperty DecadeItemsPanelTemplateProperty
DisabledDaysOfWeekProperty
Defines the DisabledDaysOfWeek property.
public static readonly DependencyProperty DisabledDaysOfWeekProperty
FirstDayOfWeekProperty
Defines the FirstDayOfWeek property.
public static readonly DependencyProperty FirstDayOfWeekProperty
IsClearButtonVisibleProperty
Defines the IsClearButtonVisible property.
public static readonly DependencyProperty IsClearButtonVisibleProperty
IsDateDisabledFuncProperty
Defines the IsDateDisabledFunc property.
public static readonly DependencyProperty IsDateDisabledFuncProperty
IsDayOfWeekSelectionEnabledProperty
Defines the IsDayOfWeekSelectionEnabled property.
public static readonly DependencyProperty IsDayOfWeekSelectionEnabledProperty
IsTodayButtonVisibleProperty
Defines the IsTodayButtonVisible property.
public static readonly DependencyProperty IsTodayButtonVisibleProperty
IsTodayHighlightedProperty
Defines the IsTodayHighlighted property.
public static readonly DependencyProperty IsTodayHighlightedProperty
IsWeekNumberColumnVisibleProperty
Defines the IsWeekNumberColumnVisible property.
public static readonly DependencyProperty IsWeekNumberColumnVisibleProperty
IsWeekNumberSelectionEnabledProperty
Defines the IsWeekNumberSelectionEnabled property.
public static readonly DependencyProperty IsWeekNumberSelectionEnabledProperty
MaxSelectionCountProperty
Defines the MaxSelectionCount property.
public static readonly DependencyProperty MaxSelectionCountProperty
MaxViewModeProperty
Defines the MaxViewMode property.
public static readonly DependencyProperty MaxViewModeProperty
MaximumProperty
Defines the Maximum property.
public static readonly DependencyProperty MaximumProperty
MinimumProperty
Defines the Minimum property.
public static readonly DependencyProperty MinimumProperty
MonthItemTemplateProperty
Defines the MonthItemTemplate property.
public static readonly DependencyProperty MonthItemTemplateProperty
MonthItemsPanelTemplateProperty
Defines the MonthItemsPanelTemplate property.
public static readonly DependencyProperty MonthItemsPanelTemplateProperty
NavigationButtonStyleProperty
Defines the NavigationButtonStyle property.
public static readonly DependencyProperty NavigationButtonStyleProperty
SelectedDateProperty
Defines the SelectedDate property.
public static readonly DependencyProperty SelectedDateProperty
SelectionModeProperty
Defines the SelectionMode property.
public static readonly DependencyProperty SelectionModeProperty
TitleButtonStyleProperty
Defines the TitleButtonStyle property.
public static readonly DependencyProperty TitleButtonStyleProperty
TitleProperty
Defines the Title property.
public static readonly DependencyProperty TitleProperty
TodayButtonStyleProperty
Defines the TodayButtonStyle property.
public static readonly DependencyProperty TodayButtonStyleProperty
TodayButtonTextProperty
Defines the TodayButtonText property.
public static readonly DependencyProperty TodayButtonTextProperty
ViewResetModeProperty
Defines the ViewResetMode property.
public static readonly DependencyProperty ViewResetModeProperty
WeekNumberItemContainerStyleProperty
Defines the WeekNumberItemContainerStyle property.
public static readonly DependencyProperty WeekNumberItemContainerStyleProperty
WeekNumberItemTemplateProperty
Defines the WeekNumberItemTemplate property.
public static readonly DependencyProperty WeekNumberItemTemplateProperty
WeekNumberItemsPanelTemplateProperty
Defines the WeekNumberItemsPanelTemplate property.
public static readonly DependencyProperty WeekNumberItemsPanelTemplateProperty
YearItemTemplateProperty
Defines the YearItemTemplate property.
public static readonly DependencyProperty YearItemTemplateProperty
YearItemsPanelTemplateProperty
Defines the YearItemsPanelTemplate property.
public static readonly DependencyProperty YearItemsPanelTemplateProperty