Skip to content

When using ListView multiselect how do I manage all selected items? #1518

Answered by tznind
Ben2146053 asked this question in Q&A
Discussion options

You must be logged in to vote

To be clear when you talk about 'getting all selections' you are meaning these right?


Tick indicates marked items

If you have a list of objects that you provided as the Source for the ListView then you can get those that have been multi selected (ticked) by using the bool IsMarked(int) method of the source. It takes the index of the list and returns true/false for whether it is ticked.

So for example if you have a ListView called lv and a List (of data objects) called myList you could use the following Linq:

myList.Where((e, idx) => lv.Source.IsMarked(idx)) 

If you don't have a copy of your original list (i.e. myList) you could still get the list of objects with something like (you could…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Ben2146053
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants