Casting error when iterating through listview in WPF

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Q123asd
    New Member
    • Oct 2011
    • 1

    Casting error when iterating through listview in WPF

    When i try to iterate through a populated WPF listview in order to remove a selected item, i get this weird, none sense of an error: cant cast string to listviewitem. (now I know what the error is implying, however; here is my code)

    Code:
    For each titem as listviewitem in listview1.items
     if titem.isselected then listview1.items.remove(titem)
    next
    The error that I am getting is at the "for each line", (where titem iterates through the list. So my question is this: If my logic is correct and the coding is correct why am i getting that casting error when I am not dealing with strings?
Working...