Skip to content

Latest commit

 

History

History
46 lines (31 loc) · 2.46 KB

listviewbase_selectrange_1824826911.md

File metadata and controls

46 lines (31 loc) · 2.46 KB
-api-id -api-type
M:Windows.UI.Xaml.Controls.ListViewBase.SelectRange(Windows.UI.Xaml.Data.ItemIndexRange)
winrt method

Windows.UI.Xaml.Controls.ListViewBase.SelectRange

-description

Selects a block of items described by the ItemIndexRange.

-parameters

-param itemIndexRange

Information about the range of items, including the index of the first and last items in the range, and the number of items.

-remarks

SelectRange and DeselectRange provide a more efficient way to modify the selection than using the SelectedItems property. When you select items using index ranges, use the SelectedRanges property to get all selected ranges in the list.

When you call SelectRange, all items in the specified range are selected, regardless of their original selection state. You can select all items in a collection by using an ItemIndexRange with a FirstIndex value of 0 and a Length value equal to the number of items in the collection.

Warning

Call the SelectRange method only when the SelectionMode property is set to Multiple or Extended. If you call SelectRange when the SelectionMode is Single or None, an exception is thrown.

Note

If the ItemsSource implements IItemsRangeInfo, the SelectedItems collection is not updated based on selection in the list. Use the SelectedRanges property instead.

-examples

Here's how to select the first 9 items in a ListView named itemListView.

if (itemListView.SelectionMode == ListViewSelectionMode.Multiple ||
    itemListView.SelectionMode == ListViewSelectionMode.Extended)
{
    itemListView.SelectRange(new ItemIndexRange(0, 9));
}

-see-also

SelectedRanges, DeselectRange, ItemIndexRange