我在 WPF 中创建了一个 ListBox,其中ItemSource
包含所有使 UI 刷新的类和事件。但是我的Remove
方法有个问题:
Public Sub Remove(ItemIndex As Integer)
MyList.RemoveAt(ItemIndex)
RaiseEvent CollectionChanged(Me, New NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, MyList(ItemIndex)))
End Sub
但是当我执行此操作时,我收到一条消息,指出索引(在这种情况下ItemIndex
)超出范围。但是在输出窗口中它说索引是'0'(否则它会从 中删除该项目MyList
)。