Is list a List<string>
? and are the items in your ListView of type ListViewItem
?
If so then try,
List<string> list = new List<string>();
foreach (ListViewItem item in ListView.Items)
{
list.Add(item.ToString());
}
Since you are getting an "unable to cast" error, it may be because the items in your ListView are not of type ListViewItem
. In that case, you can try using the ItemsSource property of the ListView to get the data source of the ListView and cast it to the appropriate type like below
List<Person> personList = new List<Person>();
foreach (Person person in ListView.ItemsSource)
{
personList.Add(person);
}