我在WPF中用ItemSource
和所有那些让UI刷新它的类和事件创建了一个ListBox。但是有一个问题,我Remove
方法:VB.NET索引'0'超出范围?
Public Sub Remove(ItemIndex As Integer)
MyList.RemoveAt(ItemIndex)
RaiseEvent CollectionChanged(Me, New NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, MyList(ItemIndex)))
End Sub
但是,当我执行此我得到一个消息,该指数(在这种情况下ItemIndex
)超出范围。但在输出窗口中,它表示索引为'0'(否则它将从MyList
中删除该项目)。
好吧,如果列表中没有项目,索引'0'(索引第一项)将超出界限。 – Oded
为什么你需要以编程方式提高事件? – peterG