Calendar Class
Represents a control that enables a user to select a date by using a visual calendar display.
Definition
Namespace: Avalonia.Controls
Assembly: Avalonia.Controls (in Avalonia.Controls.dll)
- C#
- VB
- F#
[TemplatePartAttribute("PART_CalendarItem", typeof(CalendarItem))]
[TemplatePartAttribute("PART_Root", typeof(Panel))]
public class Calendar : TemplatedControl
<TemplatePartAttribute("PART_CalendarItem", GetType(CalendarItem))>
<TemplatePartAttribute("PART_Root", GetType(Panel))>
Public Class Calendar
Inherits TemplatedControl
[<TemplatePartAttribute("PART_CalendarItem", typeof(CalendarItem))>]
[<TemplatePartAttribute("PART_Root", typeof(Panel))>]
type Calendar =
class
inherit TemplatedControl
end
Inheritance | Object → AvaloniaObject → Animatable → StyledElement → Visual → Layoutable → Interactive → InputElement → Control → TemplatedControl → Calendar |
Remarks
A Calendar control can be used on its own, or as a drop-down part of a DatePicker control. For more information, see DatePicker. A Calendar displays either the days of a month, the months of a year, or the years of a decade, depending on the value of the DisplayMode property. When displaying the days of a month, the user can select a date, a range of dates, or multiple ranges of dates. The kinds of selections that are allowed are controlled by the SelectionMode property.
The range of dates displayed is governed by the DisplayDateStart and DisplayDateEnd properties. If DisplayMode is Year or Decade, only months or years that contain displayable dates will be displayed. Setting the displayable range to a range that does not include the current DisplayDate will throw an ArgumentOutOfRangeException.
The BlackoutDates property can be used to specify dates that cannot be selected. These dates will be displayed as dimmed and disabled.
By default, Today is highlighted. This can be disabled by setting IsTodayHighlighted to false.
The Calendar control provides basic navigation using either the mouse or keyboard. The following table summarizes keyboard navigation. Key Combination DisplayMode Action ARROW Any Change focused date, unselect all selected dates, and select new focused date. SHIFT+ARROW Any If SelectionMode is not set to SingleDate or None begin selecting a range of dates. CTRL+UP ARROW Any Switch to the next larger DisplayMode. If DisplayMode is already Decade, no action. CTRL+DOWN ARROW Any Switch to the next smaller DisplayMode. If DisplayMode is already Month, no action. SPACEBAR Month Select focused date. SPACEBAR Year or Decade Switch DisplayMode to the Month or Year represented by focused item.
XAML Usage for Classes Derived from Calendar If you define a class that derives from Calendar, the class can be used as an object element in XAML, and all of the inherited properties and events that show a XAML usage in the reference for the Calendar members can have the same XAML usage for the derived class. However, the object element itself must have a different prefix mapping than the controls: mapping shown in the usages, because the derived class comes from an assembly and namespace that you create and define. You must define your own prefix mapping to an XML namespace to use the class as an object element in XAML.
Constructors
Calendar() | Initializes a new instance of the Calendar class. |
Properties
ActualThemeVariant | Gets the UI theme that is currently used by the element, which might be different than the RequestedThemeVariantProperty. (Inherited from StyledElement) |
Background | Gets or sets the brush used to draw the control's background. (Inherited from TemplatedControl) |
BackgroundSizing | Gets or sets how the control's background is drawn relative to the control's border. (Inherited from TemplatedControl) |
BlackoutDates | Gets a collection of dates that are marked as not selectable. |
BorderBrush | Gets or sets the brush used to draw the control's border. (Inherited from TemplatedControl) |
BorderThickness | Gets or sets the thickness of the control's border. (Inherited from TemplatedControl) |
Bounds | Gets the bounds of the control relative to its parent. (Inherited from Visual) |
BypassFlowDirectionPolicies | Gets a value indicating whether control bypass FlowDirecton policies. (Inherited from Visual) |
Classes | Gets or sets the styled element's classes. (Inherited from StyledElement) |
Clip | Gets or sets the geometry clip for this visual. (Inherited from Visual) |
ClipToBounds | Gets or sets a value indicating whether the control should be clipped to its bounds. (Inherited from Visual) |
ContextFlyout | Gets or sets a context flyout to the control (Inherited from Control) |
ContextMenu | Gets or sets a context menu to the control. (Inherited from Control) |
CornerRadius | Gets or sets the radius of the border rounded corners. (Inherited from TemplatedControl) |
Cursor | Gets or sets associated mouse cursor. (Inherited from InputElement) |
DataContext | Gets or sets the control's data context. (Inherited from StyledElement) |
DataTemplates | Gets or sets the data templates for the control. (Inherited from Control) |
DesiredSize | Gets the size that this element computed during the measure pass of the layout process. (Inherited from Layoutable) |
DisplayDate | Gets or sets the date to display. |
DisplayDateEnd | Gets or sets the last date to be displayed. |
DisplayDateStart | Gets or sets the first date to be displayed. |
DisplayMode | Gets or sets a value indicating whether the calendar is displayed in months, years, or decades. |
Effect | Gets or sets the effect of the control. (Inherited from Visual) |
FirstDayOfWeek | Gets or sets the day that is considered the beginning of the week. |
FlowDirection | Gets or sets the text flow direction. (Inherited from Visual) |
Focusable | Gets or sets a value indicating whether the control can receive focus. (Inherited from InputElement) |
FocusAdorner | Gets or sets the control's focus adorner. (Inherited from Control) |
FontFamily | Gets or sets the font family used to draw the control's text. (Inherited from TemplatedControl) |
FontFeatures | Gets or sets the font features turned on/off. (Inherited from TemplatedControl) |
FontSize | Gets or sets the size of the control's text in points. (Inherited from TemplatedControl) |
FontStretch | Gets or sets the font stretch used to draw the control's text. (Inherited from TemplatedControl) |
FontStyle | Gets or sets the font style used to draw the control's text. (Inherited from TemplatedControl) |
FontWeight | Gets or sets the font weight used to draw the control's text. (Inherited from TemplatedControl) |
Foreground | Gets or sets the brush used to draw the control's text and other foreground elements. (Inherited from TemplatedControl) |
GestureRecognizers | (Inherited from InputElement) |
HasMirrorTransform | Gets or sets a value indicating whether to apply mirror transform on this control. (Inherited from Visual) |
HeaderBackground | |
Height | Gets or sets the height of the element. (Inherited from Layoutable) |
HorizontalAlignment | Gets or sets the element's preferred horizontal alignment in its parent. (Inherited from Layoutable) |
InheritanceParent | Gets or sets the parent object that inherited AvaloniaProperty values are inherited from. (Inherited from AvaloniaObject) |
IsArrangeValid | Gets a value indicating whether the control's layouts arrange is valid. (Inherited from Layoutable) |
IsEffectivelyEnabled | Gets a value indicating whether this control and all its parents are enabled. (Inherited from InputElement) |
IsEffectivelyVisible | Gets a value indicating whether this control and all its parents are visible. (Inherited from Visual) |
IsEnabled | Gets or sets a value indicating whether the control is enabled for user interaction. (Inherited from InputElement) |
IsEnabledCore | Allows a derived class to override the enabled state of the control. (Inherited from InputElement) |
IsFocused | Gets a value indicating whether the control is focused. (Inherited from InputElement) |
IsHitTestVisible | Gets or sets a value indicating whether the control is considered for hit testing. (Inherited from InputElement) |
IsInitialized | Gets a value that indicates whether the element has finished initialization. (Inherited from StyledElement) |
IsKeyboardFocusWithin | Gets a value indicating whether keyboard focus is anywhere within the element or its visual tree child elements. (Inherited from InputElement) |
IsLoaded | Gets a value indicating whether the control is fully constructed in the visual tree and both layout and render are complete. (Inherited from Control) |
IsMeasureValid | Gets a value indicating whether the control's layout measure is valid. (Inherited from Layoutable) |
IsPointerOver | Gets a value indicating whether the pointer is currently over the control. (Inherited from InputElement) |
IsTabStop | Gets or sets a value that indicates whether the control is included in tab navigation. (Inherited from InputElement) |
IsTodayHighlighted | Gets or sets a value indicating whether the current date is highlighted. |
IsVisible | Gets or sets a value indicating whether this control is visible. (Inherited from Visual) |
Item(AvaloniaProperty) | Gets or sets the value of a AvaloniaProperty. (Inherited from AvaloniaObject) |
Item(IndexerDescriptor) | Gets or sets a binding for a AvaloniaProperty. (Inherited from AvaloniaObject) |
KeyBindings | (Inherited from InputElement) |
LogicalChildren | Gets the styled element's logical children. (Inherited from StyledElement) |
Margin | Gets or sets the margin around the element. (Inherited from Layoutable) |
MaxHeight | Gets or sets the maximum height of the element. (Inherited from Layoutable) |
MaxWidth | Gets or sets the maximum width of the element. (Inherited from Layoutable) |
MinHeight | Gets or sets the minimum height of the element. (Inherited from Layoutable) |
MinWidth | Gets or sets the minimum width of the element. (Inherited from Layoutable) |
Name | Gets or sets the name of the styled element. (Inherited from StyledElement) |
Opacity | Gets or sets the opacity of the control. (Inherited from Visual) |
OpacityMask | Gets or sets the opacity mask of the control. (Inherited from Visual) |
Padding | Gets or sets the padding placed between the border of the control and its content. (Inherited from TemplatedControl) |
Parent | Gets the styled element's logical parent. (Inherited from StyledElement) |
PseudoClasses | Gets the Classes collection in a form that allows adding and removing pseudoclasses. (Inherited from StyledElement) |
RenderTransform | Gets or sets the render transform of the control. (Inherited from Visual) |
RenderTransformOrigin | Gets or sets the transform origin of the control. (Inherited from Visual) |
Resources | Gets or sets the styled element's resource dictionary. (Inherited from StyledElement) |
SelectedDate | Gets or sets the currently selected date. |
SelectedDates | Gets a collection of selected dates. |
SelectionMode | Gets or sets a value that indicates what kind of selections are allowed. |
StyleKey | Gets the type by which the element is styled. (Inherited from StyledElement) |
StyleKeyOverride | Gets the type by which the element is styled. (Inherited from StyledElement) |
Styles | Gets the styles for the styled element. (Inherited from StyledElement) |
TabIndex | Gets or sets a value that determines the order in which elements receive focus when the user navigates through controls by pressing the Tab key. (Inherited from InputElement) |
Tag | Gets or sets a user-defined object attached to the control. (Inherited from Control) |
Template | Gets or sets the template that defines the control's appearance. (Inherited from TemplatedControl) |
TemplatedParent | Gets the styled element whose lookless template this styled element is part of. (Inherited from StyledElement) |
Theme | Gets or sets the theme to be applied to the element. (Inherited from StyledElement) |
Transitions | Gets or sets the property transitions for the control. (Inherited from Animatable) |
UseLayoutRounding | Gets or sets a value that determines whether the element should be snapped to pixel boundaries at layout time. (Inherited from Layoutable) |
VerticalAlignment | Gets or sets the element's preferred vertical alignment in its parent. (Inherited from Layoutable) |
VisualChildren | Gets the control's child visuals. (Inherited from Visual) |
VisualRoot | Gets the root of the visual tree, if the control is attached to a visual tree. (Inherited from Visual) |
Width | Gets or sets the width of the element. (Inherited from Layoutable) |
ZIndex | Gets or sets the Z index of the control. (Inherited from Visual) |
Methods
Events
ActualThemeVariantChanged | Raised when the theme variant is changed on the element or an ancestor of the element. (Inherited from StyledElement) |
AttachedToLogicalTree | Raised when the styled element is attached to a rooted logical tree. (Inherited from StyledElement) |
AttachedToVisualTree | Raised when the control is attached to a rooted visual tree. (Inherited from Visual) |
ContextRequested | Occurs when the user has completed a context input gesture, such as a right-click. (Inherited from Control) |
DataContextChanged | Occurs when the DataContext property changes. (Inherited from StyledElement) |
DetachedFromLogicalTree | Raised when the styled element is detached from a rooted logical tree. (Inherited from StyledElement) |
DetachedFromVisualTree | Raised when the control is detached from a rooted visual tree. (Inherited from Visual) |
DisplayDateChanged | Occurs when the DisplayDate property is changed. |
DisplayModeChanged | Occurs when the DisplayMode property is changed. |
DoubleTapped | Occurs when a double-tap gesture occurs on the control. (Inherited from InputElement) |
EffectiveViewportChanged | Occurs when the element's effective viewport changes. (Inherited from Layoutable) |
GotFocus | Occurs when the control receives focus. (Inherited from InputElement) |
Holding | Occurs when a hold gesture occurs on the control. (Inherited from InputElement) |
Initialized | Occurs when the styled element has finished initialization. (Inherited from StyledElement) |
KeyDown | Occurs when a key is pressed while the control has focus. (Inherited from InputElement) |
KeyUp | Occurs when a key is released while the control has focus. (Inherited from InputElement) |
LayoutUpdated | Occurs when a layout pass completes for the control. (Inherited from Layoutable) |
Loaded | Occurs when the control has been fully constructed in the visual tree and both layout and render are complete. (Inherited from Control) |
LostFocus | Occurs when the control loses focus. (Inherited from InputElement) |
PointerCaptureLost | Occurs when the control or its child control loses the pointer capture for any reason, event will not be triggered for a parent control if capture was transferred to another child of that parent control (Inherited from InputElement) |
PointerEntered | Occurs when the pointer enters the control. (Inherited from InputElement) |
PointerExited | Occurs when the pointer leaves the control. (Inherited from InputElement) |
PointerMoved | Occurs when the pointer moves over the control. (Inherited from InputElement) |
PointerPressed | Occurs when the pointer is pressed over the control. (Inherited from InputElement) |
PointerReleased | Occurs when the pointer is released over the control. (Inherited from InputElement) |
PointerWheelChanged | Occurs when the mouse is scrolled over the control. (Inherited from InputElement) |
PropertyChanged | Raised when a AvaloniaProperty value changes on this object. (Inherited from AvaloniaObject) |
ResourcesChanged | Occurs when a resource in this styled element or a parent styled element has changed. (Inherited from StyledElement) |
SelectedDatesChanged | |
SizeChanged | Occurs when the bounds (actual size) of the control have changed. (Inherited from Control) |
Tapped | Occurs when a tap gesture occurs on the control. (Inherited from InputElement) |
TemplateApplied | Raised when the control's template is applied. (Inherited from TemplatedControl) |
TextInput | Occurs when a user typed some text while the control has focus. (Inherited from InputElement) |
TextInputMethodClientRequested | Occurs when an input element gains input focus and input method is looking for the corresponding client (Inherited from InputElement) |
Unloaded | Occurs when the control is removed from the visual tree. (Inherited from Control) |