.NET MAUI ListPicker Selection
The ListPicker for .NET MAUI enables the application users to select an item from a list of items. This topic will go through the provided by the ListPicker API related to item selection.
Selected Item Properties
The SelectedItem
(object
) property specifies the selected item of the ListPicker.
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 DateTimePicker:
Methods
The ListPicker for .NET MAUI allows you to clear the selected date/time through its ClearSelection
method.
The following example demonstrates how to use the ClearSelection
method of the ListPicker.
1. Define the ListPicker:
2. Clear the selection inside the button click
event:
3. Set a sample ViewModel
:
4. Define the Business model:
5. Add the following namespace:
Events
The ListPicker for .NET MAUI exposes a SelectionChanged
event which is raised when the user confirms the selected item.
The following example demonstrates how to use the SelectionChanged
event of the ListPicker.
1. Define the ListPicker:
2. Set the SelectionChanged
event, where sender
corresponds to the ListPicker control:
3. Define a sample ViewModel
:
4. Set the Business model. In the example, the sender
is the ListPicker control.
5. Add the following namespace: