我有一个ListView控件,我ListView.ItemsSource使用实现ISupportIncrementalLoading/的集合类异步加载(通过设置)INotifyCollectionChanged。当我尝试调用INotifyCollectionChanged事件订阅者时,我得到ArgumentOutOfRangeException“此集合无法使用大于 Int32.MaxValue - 1 (0x7FFFFFFF - 1) 的索引。\r\n参数名称:索引”异常。我几乎尝试了 NotifyCollectionChangedEventArgs 构造函数的每个重载。无论我做什么,我总是遇到同样的例外。我没有发现我传递给事件处理程序的 NotifyCollectionChangedEventArgs 对象有任何问题。有任何想法吗?public class GroupDataSource<T> : ObservableCollection<T>, INotifyCollectionChanged, ISupportIncrementalLoading where T : SDataEntity, new(){ ... async Task NotifyOfInsertedItems(int baseIndex, int count) { await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { foreach (NotifyCollectionChangedEventHandler handler in _eventHandlers) { for (int i = 0; i < count; i++) { var args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, _items[i + baseIndex], i + baseIndex); try { handler(this, args); } catch(Exception e) { //todo: log it //this is where I get System.ArgumentOutOfRangeException } } } } ); }
添加回答
举报
0/150
提交
取消