Vixen
feb85697
csharp
public sealed class DatePicker

A field showing a date, with a calendar behind it.

Read the guide page for this →

Remarks

The second half of doc 49 § 7.1's rank 5. A Select whose list is a Calendar: the same field, the same chevron, the same popover hung off the document root so no scrolling ancestor clips it, and the same combobox role with Owns pointing at a popup that is nowhere near it in the element tree.

⚠ The keyboard goes into the calendar when it opens, which is where this parts company with Select. A select keeps the focus on its field and points at the current option with aria-activedescendant, because its options are a list the arrows walk. A calendar is a grid a user walks in four directions and pages through, and ARIA's date-picker pattern puts the focus on the day. Escape, a click outside and a choice all close it and give the keyboard back to the field.

⚠ It validates, so a Form asks it. Required and a date outside Minimum..Maximum — which a bound model can supply, even though the calendar will not offer one — both make it refuse a submission.

What it deliberately is not. The field cannot be typed into: a date is chosen from the calendar, or set by code. Typing a date is a parser per locale and a mask, and a field that half-parsed a date would be worse than one that shows it.

Fields and properties (21)

  • protected override string TagName

    The element name this type answers to when a caller does not choose one.

  • protected override AccessibleRole NativeRole

    The role this kind of element has when nobody says otherwise.

  • protected override string? NativeAccessibleValue
  • protected override AccessibleStates NativeAccessibleState
  • public UiElement Field

    Where the date is written.

  • public Icon Chevron

    The chevron on the right of the field.

  • public Popover Popup

    The floating panel the calendar is in.

  • public Calendar Calendar

    The calendar in it.

  • public bool IsOpen

    Whether the calendar is showing.

  • public DateOnly? Value
  • public DateOnly? Minimum
  • public DateOnly? Maximum
  • public bool Required
  • public string? Placeholder
  • public CultureInfo? Culture

    Which locale the date is written in and the calendar is laid out in. null is invariant.

  • public bool IsValid

    Whether the date held is acceptable: present if it is required, and inside the limits.

  • public static readonly UiPropertyKey ValueProperty

    Identity for Value.

  • public static readonly UiPropertyKey MinimumProperty

    Identity for Minimum.

  • public static readonly UiPropertyKey MaximumProperty

    Identity for Maximum.

  • public static readonly UiPropertyKey RequiredProperty

    Identity for Required.

  • public static readonly UiPropertyKey PlaceholderProperty

    Identity for Placeholder.

Events (1)

  • public Action<DatePicker, DateOnly?>? ValueChanged

    Raised when the chosen date changes.

Methods (10)

  • protected override void OnCreated()

    Builds whatever this element is made of, once, as it joins a document.

  • protected override void OnRemoved()
  • public void Open()

    Shows the calendar and puts the keyboard on its chosen day, or on today.

  • public void Close(CloseReason reason = Code)

    Hides the calendar.

  • public void Revalidate()

    Republishes the verdict.

  • public void ClearValue()

    Unsets Value, so it takes its default or its ancestor's value again.

  • public void ClearMinimum()

    Unsets Minimum, so it takes its default or its ancestor's value again.

  • public void ClearMaximum()

    Unsets Maximum, so it takes its default or its ancestor's value again.

  • public void ClearRequired()

    Unsets Required, so it takes its default or its ancestor's value again.

  • public void ClearPlaceholder()

    Unsets Placeholder, so it takes its default or its ancestor's value again.

Used by (3)

  • GalleryHelloUi
  • DatePickerTestsVixen.Ui.Controls.Tests
  • FieldFillTestsVixen.Ui.Controls.Tests