INotifyCollectionChanged: Added item does not appear at given index '0'

前端 未结 3 1231
情歌与酒
情歌与酒 2020-12-20 18:03

I\'m making a observable class. The Add methods works fine. But then I\'m trying to call the Remove() method I get this error:

\"Added item does not a

3条回答
  •  情歌与酒
    2020-12-20 18:26

    Are you sure the error is with the Remove method? The error message and your source code indicate it is in the Add method. Try using the correct index _list.Count - 1 in the constructor of NotifyCollectionChangedEventArgs:

    CollectionChanged(this, new NotifyCollectionChangedEventArgs(
                                                  NotifyCollectionChangedAction.Add, 
                                                  orderResponse, _list.Count - 1)
                     );
    

提交回复
热议问题