private void PopulatePageData(int startIndex, IList <T> pageData, int overallCount) { bool flagRefresh = false; if (_list == null || _list.Length != overallCount) { _list = new VirtualListItem <T> [overallCount]; flagRefresh = true; } for (int i = 0; i < pageData.Count; i++) { int index = startIndex + i; if (_list[index] == null) { _list[index] = new VirtualListItem <T>(this, index, pageData[i]); } else { _list[index].Data = pageData[i]; } } if (flagRefresh) { if (this._synchronizationContext == null || SynchronizationContext.Current != null) { FireCollectionReset(null); } else { _synchronizationContext.Send(FireCollectionReset, null); } } }
private void SetCurrent(VirtualListItem <T> newItem, int newPosition) { bool isCurrentBeforeFirst = _isCurrentBeforeFirst; bool isCurrentAfterLast = _isCurrentAfterLast; VirtualListItem <T> currentItem = _currentItem; int currentPosition = _currentPosition; _isCurrentBeforeFirst = newPosition < 0; _isCurrentAfterLast = newPosition >= Count; _currentItem = newItem; _currentPosition = newPosition; if (currentItem != _currentItem) { OnCurrentChanged(); } if (isCurrentBeforeFirst != _isCurrentBeforeFirst) { OnPropertyChanged(_isCurrentBeforeFirstChanged); } if (isCurrentAfterLast != _isCurrentAfterLast) { OnPropertyChanged(_isCurrentAfterLastChanged); } if (currentItem != _currentItem) { OnPropertyChanged(_currentItemChanged); } if (currentPosition != _currentPosition) { OnPropertyChanged(_currentPositionChanged); } }
public VirtualListItem <T> this[int index] { get { if (_list[index] == null) { _list[index] = new VirtualListItem <T>(this, index); } return(_list[index]); } set { throw new NotSupportedException(); } }
bool ICollection <VirtualListItem <T> > .Remove(VirtualListItem <T> item) { throw new NotSupportedException(); }
void ICollection <VirtualListItem <T> > .Add(VirtualListItem <T> item) { throw new NotSupportedException(); }
void IList <VirtualListItem <T> > .Insert(int index, VirtualListItem <T> item) { throw new NotSupportedException(); }
public int IndexOf(VirtualListItem <T> item) { return(item == null || item.List != this ? -1 : item.Index); }
public bool Contains(VirtualListItem <T> item) { return(IndexOf(item) != -1); }