0

I'm having trouble with gathering data from multiple selected item from listvew. Let's say I have 10 items, if I select 5 of them, is there a way to store them into some kind of a array or something? My listview is like below:

<ListView x:Name="listView1" ScrollViewer.VerticalScrollBarVisibility="Auto"
   ScrollViewer.VerticalScrollMode="Enabled" SelectionMode="Multiple"/>
2
  • ListView has a SelectedItems property. Commented Mar 3, 2018 at 14:45
  • Yea I noticed but when I check its value, I dont remember exacly but its something like system.context. So not the values that I want :S Commented Mar 3, 2018 at 14:55

1 Answer 1

1

You can use the SelectedItems property, which is an IList<object>. You can enumerate it like this:

foreach ( var selectedItem in listView.SelectedItems.OfType<XXX>() )
{
    //do something
}

Where XXX is the type of collection you bind to the ListView.

Furthermore you can use UWP Behaviors to trigger command whenever selection changes. See this blog post for more details.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.