question

65010773 avatar image
65010773 asked ·

How to remove all items from listview

Hi

I have a listview that i populated using an ObservableCollection.
I would like to remove all items from the listview

 Private ReadOnly collectionresult As New ObservableCollection(Of Classresult)

' i tried this but i an exception is raised
'Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
Try
For iter = panelresult.Items.Count - 1 To 0 Step -1
panelresult.Items.RemoveAt(iter)
Next
Catch ex As Exception
Dim strex As String = ex.Message
End Try

     panelresult.ItemsSource = collectionresult

the xaml
22842-listview.png



Thanks

windows-uwp-xaml
listview.png (75.1 KiB)
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

NicoZhu-MSFT avatar image
NicoZhu-MSFT answered ·

Hello,
Welcome to Microsoft Q&A,

How to remove all items from listview

If you want to remove all items from listview, you could call ObservableCollection Clear method.

 collectionresult.Clear();

Thanks
Nico Zhu

Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.