无法从 Windows Phone 8.1 中的 ListView 控件中删除项目

Unable to remove Item from ListView control in Windows Phone 8.1

我正在尝试使用 RemoveAt() 函数从 listview 控件中删除一个项目,但出现以下错误:

Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

我正在使用以下代码删除项目:

void remove (object sender)
{
    var item = (sender as FrameworkElement).DataContext;
    int index = PropSearchList.Items.IndexOf(item);
    PropSearchList.Items.RemoveAt(index);
}

只需在 UI 个线程中完成

Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () => PropSearchList.Items.RemoveAt(index));

更新:

您可以使用 ObservableCollection 并从您的来源中删除项目。为您的 cachedData 创建一个实例并重写代码:

private ObservableCollection<T> cachedData;
...
PropSearchList.ItemsSource = cachedData;
...
Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () => cachedData.RemoveAt(index));