I am trying to remove an item from listview
control using RemoveAt()
function but I am getting the following error:
Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
I am using the following code to remove item:
void remove (object sender)
{
var item = (sender as FrameworkElement).DataContext;
int index = PropSearchList.Items.IndexOf(item);
PropSearchList.Items.RemoveAt(index);
}
Just do it in UI thread
Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () => PropSearchList.Items.RemoveAt(index));
You can use ObservableCollection
and remove items from your source. Create an instance for your cachedData
and rewrite come code:
private ObservableCollection<T> cachedData;
...
PropSearchList.ItemsSource = cachedData;
...
Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () => cachedData.RemoveAt(index));
User contributions licensed under CC BY-SA 3.0