Class CalendarDatePicker
A date selection control that allows the user to select dates from a drop down calendar.
[TemplatePart("PART_Button", typeof(Button))]
[TemplatePart("PART_Calendar", typeof(Calendar))]
[TemplatePart("PART_Popup", typeof(Popup))]
[TemplatePart("PART_TextBox", typeof(TextBox))]
[PseudoClasses(new string[] { ":flyout-open", ":pressed" })]
public class CalendarDatePicker : TemplatedControl, INotifyPropertyChanged, IDataContextProvider, ILogical, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, ISupportInitialize, IStyleable, INamed, IInputElement, IDataTemplateHost, ISetterValue
- Inheritance
-
CalendarDatePicker
- Implements
- Inherited Members
- Extension Methods
Constructors
CalendarDatePicker()
Initializes a new instance of the CalendarDatePicker class.
public CalendarDatePicker()
Fields
CustomDateFormatStringProperty
Defines the CustomDateFormatString property.
public static readonly StyledProperty<string> CustomDateFormatStringProperty
Field Value
DisplayDateEndProperty
Defines the DisplayDateEnd property.
public static readonly StyledProperty<DateTime?> DisplayDateEndProperty
Field Value
DisplayDateProperty
Defines the DisplayDate property.
public static readonly StyledProperty<DateTime> DisplayDateProperty
Field Value
DisplayDateStartProperty
Defines the DisplayDateStart property.
public static readonly StyledProperty<DateTime?> DisplayDateStartProperty
Field Value
FirstDayOfWeekProperty
Defines the FirstDayOfWeek property.
public static readonly StyledProperty<DayOfWeek> FirstDayOfWeekProperty
Field Value
HorizontalContentAlignmentProperty
Defines the HorizontalContentAlignment property.
public static readonly StyledProperty<HorizontalAlignment> HorizontalContentAlignmentProperty
Field Value
IsDropDownOpenProperty
Defines the IsDropDownOpen property.
public static readonly StyledProperty<bool> IsDropDownOpenProperty
Field Value
IsTodayHighlightedProperty
Defines the IsTodayHighlighted property.
public static readonly StyledProperty<bool> IsTodayHighlightedProperty
Field Value
SelectedDateFormatProperty
Defines the SelectedDateFormat property.
public static readonly StyledProperty<CalendarDatePickerFormat> SelectedDateFormatProperty
Field Value
SelectedDateProperty
Defines the SelectedDate property.
public static readonly StyledProperty<DateTime?> SelectedDateProperty
Field Value
TextProperty
Defines the Text property.
public static readonly StyledProperty<string?> TextProperty
Field Value
UseFloatingWatermarkProperty
Defines the UseFloatingWatermark property.
public static readonly StyledProperty<bool> UseFloatingWatermarkProperty
Field Value
VerticalContentAlignmentProperty
Defines the VerticalContentAlignment property.
public static readonly StyledProperty<VerticalAlignment> VerticalContentAlignmentProperty
Field Value
WatermarkProperty
Defines the Watermark property.
public static readonly StyledProperty<string?> WatermarkProperty
Field Value
Properties
BlackoutDates
Gets a collection of dates that are marked as not selectable.
public CalendarBlackoutDatesCollection? BlackoutDates { get; }
Property Value
- CalendarBlackoutDatesCollection
A collection of dates that cannot be selected. The default value is an empty collection.
CustomDateFormatString
public string CustomDateFormatString { get; set; }
Property Value
DisplayDate
Gets or sets the date to display.
public DateTime DisplayDate { get; set; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The specified date is not in the range defined by DisplayDateStart and DisplayDateEnd.
DisplayDateEnd
Gets or sets the last date to be displayed.
public DateTime? DisplayDateEnd { get; set; }
Property Value
- DateTime?
The last date to display.
DisplayDateStart
Gets or sets the first date to be displayed.
public DateTime? DisplayDateStart { get; set; }
Property Value
- DateTime?
The first date to display.
FirstDayOfWeek
Gets or sets the day that is considered the beginning of the week.
public DayOfWeek FirstDayOfWeek { get; set; }
Property Value
HorizontalContentAlignment
Gets or sets the horizontal alignment of the content within the control.
public HorizontalAlignment HorizontalContentAlignment { get; set; }
Property Value
IsDropDownOpen
Gets or sets a value indicating whether the drop-down Calendar is open or closed.
public bool IsDropDownOpen { get; set; }
Property Value
IsTodayHighlighted
Gets or sets a value indicating whether the current date will be highlighted.
public bool IsTodayHighlighted { get; set; }
Property Value
- bool
True if the current date is highlighted; otherwise, false. The default is true.
SelectedDate
Gets or sets the currently selected date.
public DateTime? SelectedDate { get; set; }
Property Value
- DateTime?
The date currently selected. The default is null.
Exceptions
- ArgumentOutOfRangeException
The specified date is not in the range defined by DisplayDateStart and DisplayDateEnd, or the specified date is in the BlackoutDates collection.
SelectedDateFormat
Gets or sets the format that is used to display the selected date.
public CalendarDatePickerFormat SelectedDateFormat { get; set; }
Property Value
- CalendarDatePickerFormat
The format that is used to display the selected date. The default is Short.
Exceptions
- ArgumentOutOfRangeException
An specified format is not valid.
Text
Gets or sets the text that is displayed by the CalendarDatePicker.
public string? Text { get; set; }
Property Value
- string
The text displayed by the CalendarDatePicker.
Exceptions
- FormatException
The text entered cannot be parsed to a valid date, and the exception is not suppressed.
- ArgumentOutOfRangeException
The text entered parses to a date that is not selectable.
UseFloatingWatermark
Gets or sets a value indicating whether the Watermark will still be shown above the Text even after a text value is set.
public bool UseFloatingWatermark { get; set; }
Property Value
VerticalContentAlignment
Gets or sets the vertical alignment of the content within the control.
public VerticalAlignment VerticalContentAlignment { get; set; }
Property Value
Watermark
Gets or sets the placeholder or descriptive text that is displayed even if the Text property is not yet set.
public string? Watermark { get; set; }
Property Value
Methods
Clear()
Clear SelectedDate.
public void Clear()
OnApplyTemplate(TemplateAppliedEventArgs)
Called when the control's template is applied. In simple terms, this means the method is called just before the control is displayed.
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
Parameters
e
TemplateAppliedEventArgsThe event args.
OnDateValidationError(CalendarDatePickerDateValidationErrorEventArgs)
Raises the DateValidationError event.
protected virtual void OnDateValidationError(CalendarDatePickerDateValidationErrorEventArgs e)
Parameters
e
CalendarDatePickerDateValidationErrorEventArgsA CalendarDatePickerDateValidationErrorEventArgs that contains the event data.
OnGotFocus(GotFocusEventArgs)
Called before the GotFocus event occurs.
protected override void OnGotFocus(GotFocusEventArgs e)
Parameters
e
GotFocusEventArgsThe event args.
OnKeyUp(KeyEventArgs)
Called before the KeyUp event occurs.
protected override void OnKeyUp(KeyEventArgs e)
Parameters
e
KeyEventArgsThe event args.
OnLostFocus(RoutedEventArgs)
Called before the LostFocus event occurs.
protected override void OnLostFocus(RoutedEventArgs e)
Parameters
e
RoutedEventArgsThe event args.
OnPointerCaptureLost(PointerCaptureLostEventArgs)
Called before the PointerCaptureLost event occurs.
protected override void OnPointerCaptureLost(PointerCaptureLostEventArgs e)
Parameters
e
PointerCaptureLostEventArgsThe event args.
OnPointerPressed(PointerPressedEventArgs)
Called before the PointerPressed event occurs.
protected override void OnPointerPressed(PointerPressedEventArgs e)
Parameters
e
PointerPressedEventArgsThe event args.
OnPointerReleased(PointerReleasedEventArgs)
Called before the PointerReleased event occurs.
protected override void OnPointerReleased(PointerReleasedEventArgs e)
Parameters
e
PointerReleasedEventArgsThe event args.
OnPointerWheelChanged(PointerWheelEventArgs)
Called before the PointerWheelChanged event occurs.
protected override void OnPointerWheelChanged(PointerWheelEventArgs e)
Parameters
e
PointerWheelEventArgsThe event args.
OnPropertyChanged(AvaloniaPropertyChangedEventArgs)
Called when a avalonia property changes on the object.
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
Parameters
change
AvaloniaPropertyChangedEventArgsThe property change details.
UpdateDataValidation(AvaloniaProperty, BindingValueType, Exception?)
Called to update the validation state for properties for which data validation is enabled.
protected override void UpdateDataValidation(AvaloniaProperty property, BindingValueType state, Exception? error)
Parameters
property
AvaloniaPropertyThe property.
state
BindingValueTypeThe current data binding state.
error
ExceptionThe current data binding error, if any.
UpdatePseudoClasses()
Updates the visual state of the control by applying latest PseudoClasses.
protected void UpdatePseudoClasses()
Events
CalendarClosed
Occurs when the drop-down Calendar is closed.
public event EventHandler? CalendarClosed
Event Type
CalendarOpened
Occurs when the drop-down Calendar is opened.
public event EventHandler? CalendarOpened
Event Type
DateValidationError
Occurs when Avalonia.Controls.DatePicker.Text is assigned a value that cannot be interpreted as a date.
public event EventHandler<CalendarDatePickerDateValidationErrorEventArgs>? DateValidationError
Event Type
SelectedDateChanged
Occurs when the SelectedDate property is changed.
public event EventHandler<SelectionChangedEventArgs>? SelectedDateChanged