Steini
Steini

Reputation: 485

UWP: Select multiple items of a ListView in code behind

In my UWP App, I have a ListView with Items. How can I select Items of the ListView in code behind?

I have tried to add Items to the SelectedItems of the ListView, or use the SelectRange() method of the ListView. Nothing has worked so far.

Upvotes: 1

Views: 535

Answers (1)

Nico Zhu
Nico Zhu

Reputation: 32785

Set SelectedItems of a ListView in CodeBehind

You could use SelectRange method to select ListViewItem in code behind. But we need set the SelectionMode as Extended before call SelectRange method (The default is Single selection).

TestListView.SelectRange(new ItemIndexRange(0, 3));

Upvotes: 2

Related Questions