DatePicker
Note: You can check the Avalonia docs for the DatePicker and DatePicker API if you need more information.
The DatePicker control is a single date picker that displays a calendar, it is also possible to enter a date via the TextBox the control has
Set Label
DatePicker.create [
DatePicker.header "Title"
]
Set Date
DatePicker.create [
DatePicker.selectedDate DateTime.Today
]
Set DateFormat
DatePicker.create [
DatePicker.yearFormat "yyyy"
DatePicker.monthFormat "MMMM"
DatePicker.dayFormat "dd"
]
You can check Custom date and time format strings Microsoft docs for more information about the format strings.
Limit Year Range
DatePicker.create [
DatePicker.maxYear (DateTimeOffset(DateTime.Now))
]
Show Only Month and Year
You can control the visibility of the day, month, and year with similarly named functions.
DatePicker.create [
DatePicker.dayVisible false
]
Register Selected Date
DatePicker.create [
DatePicker.onSelectedDateChanged (fun dateOffset -> OnChangeDateOffset dateOffset |> dispatch)
]
Last modified 10mo ago