.NET MAUI ListPicker Commands
This article describes the commands available in the Telerik UI for .NET MAUI ListPicker control.
ListPicker Commands
List Picker for .NET MAUI exposes the following commands you can use to programmatically manipulate displaying the popup as well as clearing the selected item:
-
ToggleCommand
(ICommand
)—Allows you to show/hide the popup used for selecting an item from a list of items. -
ClearCommand
(ICommand
)—Allows you to clear the displayed item.
OK and Cancel Buttons
Through the popup or the drop-down, users can pick an item. This must be confirmed or rejected with the OK or Cancel buttons located in the popup or drop-down.
The ListPicker allows you to add a custom logic for the Accept
and Cancel
commands which are executed when the OK or Cancel buttons are clicked.
-
AcceptCommand
(ICommand
)—Defines the command, which confirms the current selection of the picker and closes the popup or drop-down. UseAcceptCommandParameter
to pass a parameter to the command execute method. -
CancelCommand
(ICommand
)—Defines the command, which rejects the current selection of the picker and closes the popup or drop-down. UseCancelCommandParameter
to pass a parameter to the command execute method.
You can apply the Accept
and Cancel
commands for the popup mode by setting the PopupSettings
property of the ListPicker. For the drop-down mode, use the DropDownSettings
property.
Example
The example shows how to define the commands in the PopupSettings
. The same is valid for the DropDownSettings
.
1. Define the ListPicker:
2. Set the sample ViewModel
:
3. Add the Business model:
4. Add the following namespace: