.NET MAUI TimeSpanPicker Selection
The TimeSpanPicker control enables users to select a time interval. This topic explains the TimeSpanPicker API related to the time-interval selection.
Time Property
To define the current time-interval selection, use the Time
(TimeSpan?
) property. The default value is null
.
The following example shows how to set the Time
property.
Define the TimeSpanPicker.
Add the namespace.
Clear Button
You can enable a Clear button which can be used to quickly remove the selected value. To enable the button, set IsClearButtonVisible
property of the TimePicker:
Methods
To cancel the selected time, use the ClearSelection
method.
The following example shows how to set the ClearSelection
method.
1. Define the TimeSpanPicker.
2. Add the namespace.
3. Call ClearSelection
inside the button click
event. As a result, the Time
property will be updated to null
.
Events
The TimeSpanPicker exposes the SelectionChanged
event, which is raised when the user picks a time value.
The following example shows how to set the SelectionChanged
event.
1. Define the TimeSpanPicker:
2. Add the namespace:
3. Define the SelectionChanged
event where the sender
is the RadTimeSpanPicker
control: