Reputation: 205
I have a ListView with string items, and i am trying to get these items and store them in List container.
I need the reverse operation of this:
List<string> myList = new List<string> { "Item1", "item2", "item3"};
resultsList.ItemsSource = myList;
So my Question is How to Parse ListView with Items to List?
Upvotes: 0
Views: 493
Reputation: 460108
I think you can cast and use ToList
to create a list:
myList = resultsList.ItemsSource.Cast<string>().ToList();
Upvotes: 2
Reputation: 23087
You need to cast it to IEnumerable<string>
List<string> myList = ((IEnumerable<string>)resultsList.ItemsSource).ToList();
Upvotes: 3