.NET MAUI ListPicker Templates
The ListPicker for .NET MAUI provides the following templates:
-
ItemTemplate
(DataTemplate
)—Defines the template used for displaying the list of items. -
SelectedItemTemplate
(DataTemplate
)—Specifies the template used for visualizing the selected item from the list. -
PlaceholderTemplate
(ControlTemplate
)—Defines the template visualized for the placeholder.
-
DisplayTemplate
(ControlTemplate
)—Defines the template visualized when an item from the list is selected.
Using SelectorSettings
property (of type Telerik.Maui.Controls.PickerPopupSelectorSettings
) you can define the following templates:
-
HeaderTemplate
(ControlTemplate
)—Defines what will be displayed inside the dialog(popup) header. -
FooterTemplate
(ControlTemplate
)—Defines what will be displayed inside the dialog(popup) footer.
This is the Visual Structure of the ListPicker templates:
In addition, the ListPicker for .NET MAUI provides the following properties:
-
ItemsSource
(IList
)—Specifies the collection used to generate the content of the list picker. -
ItemLength
(double
)—Defines the length of the items inside the list. -
ItemSpacing
(double
)—Defines the spacing between the items inside the list. -
SelectedItem
(object
)—Specifies the selected item of the list picker -
DisplayMemberPath
(string
)—Defines the path of the property which is to be displayed asDisplayString
.
Example
The following example demonstrates how to define a sample ListPicker:
Define the templates in the page resources:
Item Template
Template for the Selected Item
Placeholder Template
Display Template
Header Template
Footer Template
Set a sample business model:
Define the ViewModel
:
Add the following namespace:
The following image shows the end result:
For a sample templates example, refer to the ListPicker/Templates folder of the Telerik UI for .NET MAUI SDKBrowser Application.