Selection
RadListView supports a selection feature which triggers by a click or tap on a list view item.
The selection is enabled by default and it supports the following modes:
- Single: Single item can be selected (default).
- Multiple: Multiple items can be selected.
- Extended: Single item can be selected, unless you hold the Ctrl key. This allows multiple selection.
- None: No selection is allowed.
The selection mode is controlled with the SelectionMode property (of type DataControlsSelectionMode) of RadListView.
The selected items can be set or get with the SelectedItem and SelectedItems properties of RadListView.
The selection can be set also with the the following methods:
- SelectItem(object item): Selects the specified data item and adds it in the SelectedItems collection.
- DeselectItem(object item): Removes the selection for the specified data item and removes it from the SelectedItems collection.
- SelectAll(): If multiple selection is allowed, this method selects all items in the list view.
- DeselectAll(): Clears the currently selected items.
The click/tap over an item raises the following actions:
- The SelectionChanged event of RadListView.
- The CollectionChanged event of the SelectedItems collection.
- The ItemTapCommand. Read more in the Commands article.
Example
Example 1: Setting SelectionMode
<telerikData:RadListView x:Name="listView" SelectionMode="Multiple"/>
<!-- where telerikData
points to xmlns:telerikData="using:Telerik.UI.Xaml.Controls.Data" -->
Example 2: Selecting items in code
this.listView.ItemsSource = Enum.GetNames(typeof(DayOfWeek)).ToList();
this.listView.SelectItem("Sunday");
this.listView.SelectItem("Tuesday");
this.listView.SelectItem("Wednesday");