.NET MAUI DatePicker Selection
The Telerik UI for .NET MAUI DatePicker control enables the application users to quickly and easily select a date value by providing an API related to date selection.
Setting the Current Date Selection
To define the current date selection, use the Date
(DateTime?
) property. By default, Date
is null
.
-
Define the DatePicker and set the
Date
property.<telerik:RadDatePicker Date="2020,05,15" SpinnerFormat="yyy-MMM"/>
-
Add the following namespace:
xmlns:telerik="http://schemas.telerik.com/2022/xaml/maui"
Clearing the Selection through UI
You can enable the removal of the selected value by rendering a Clear button through the IsClearButtonVisible
property of the DatePicker:
<telerik:RadDatePicker Date="2020,05,15"
IsClearButtonVisible="True" />
Clearing the Selection Programmatically
The DatePicker for .NET MAUI allows you to clear the selected date through its ClearSelection
method.
-
Define the DatePicker and set the method:
<StackLayout> <Button Text="Clear Selection" Clicked="OnClearSelectionClicked"/> <telerik:RadDatePicker x:Name="datePicker"/> </StackLayout>
-
Add the following namespace:
xmlns:telerik="http://schemas.telerik.com/2022/xaml/maui"
-
Call
ClearSelection
inside the buttonclick
event. As a result, theDate
property will be updated tonull
.private void OnClearSelectionClicked(object sender, EventArgs e) { this.datePicker.ClearSelection(); }
Modifying the Selection
The DatePicker exposes a SelectionChanged
event, which is raised when the user picks a date value.
-
Set the
SelectionChanged
event.<telerik:RadDatePicker SelectionChanged="RadDatePicker_SelectionChanged"/>
-
Add the following namespace:
xmlns:telerik="http://schemas.telerik.com/2022/xaml/maui"
-
Add the
SelectionChanged
event, where thesender
is theRadDatePicker
instance.private void RadDatePicker_SelectionChanged(object sender, EventArgs e) { // Implement your logic here. }
See Also