Class DatePicker
A component for selecting dates with an intuitive calendar interface.
Inheritance
Implements
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
[UxmlElement]
public class DatePicker : BaseDatePicker, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IContextOverrideElement, IAdditionalDataHolder, INotifyValueChanged<Date>
Remarks
The DatePicker component provides an intuitive way to select dates through a calendar interface. It supports various display modes including days, months, and years views, making it flexible for different date selection needs.
The component follows common date picker patterns found in modern applications, with navigation controls for moving between months and years, and a clear visual hierarchy for date selection.
Key features include:
- Three display modes: days, months, and years views
- Navigation between months and years
- Configurable first day of the week
- Localization support
- Keyboard navigation support
- Full UXML support
NOTE: The DatePicker supports both programmatic and user interface-based date selection.
Examples
Basic usage in UXML. Create a simple date picker with default settings.
<UXML xmlns:appui="Unity.AppUI.UI">
<appui:DatePicker name="date-picker" />
</UXML>
Creating a pre-configured date picker in UXML. Create a date picker with custom initial date, first day of week, and display mode.
<UXML xmlns:appui="Unity.AppUI.UI">
<appui:DatePicker
name="custom-date-picker"
value="2024-01-01"
first-day-of-week="Monday"
display-mode="Months" />
</UXML>
Creating and configuring a date picker in C#. Create a date picker, set its initial value, configure it, and handle value changes.
var datePicker = new DatePicker();
datePicker.value = new Date(2024, 1, 1);
datePicker.firstDayOfWeek = DayOfWeek.Monday;
// Register for value changes
datePicker.RegisterValueChangedCallback(evt => {
Debug.Log($"Selected date: ");
});
Constructors
DatePicker()
Default constructor.
Declaration
public DatePicker()
Properties
value
The current value of the date picker.
Declaration
[CreateProperty]
[UxmlAttribute]
public Date value { get; set; }
Property Value
| Type | Description |
|---|---|
| Date |
Methods
SetValueWithoutNotify(Date)
Set the value of the date picker without sending a change event.
Declaration
public void SetValueWithoutNotify(Date newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| Date | newValue | The new value. |