internal int Remove(object item, bool returnLeafIndex) { int index = -1; int localIndex = ProtectedItems.IndexOf(item); if (localIndex >= 0) { if (returnLeafIndex) { index = LeafIndexFromItem(null, localIndex); } CollectionViewGroupInternal subGroup = item as CollectionViewGroupInternal; if (subGroup != null) { subGroup.Clear(); // Remove from the name to group map. RemoveSubgroupFromMap(subGroup); } ChangeCounts(item, -1); // ChangeCounts may clear this group, if it is now empty. // In that case, don't use localIndex - it's now out of range. if (ProtectedItems.Count > 0) { ProtectedItems.RemoveAt(localIndex); } } return(index); }
/// <summary> /// Removes the specified item from the collection /// </summary> /// <param name="item">Item to remove</param> /// <param name="returnLeafIndex">Whether we want to return the leaf index</param> /// <returns>Leaf index where item was removed, if value was specified. Otherwise '-1'</returns> internal int Remove(object item, bool returnLeafIndex) { int index = -1; int localIndex = ProtectedItems.IndexOf(item); if (localIndex >= 0) { if (returnLeafIndex) { index = LeafIndexFromItem(null, localIndex); } ChangeCounts(item, -1); ProtectedItems.RemoveAt(localIndex); } return(index); }
internal void RemoveSpecialItem(int index, object item, bool loading) { Debug.Assert(Object.Equals(item, ProtectedItems[index]), "RemoveSpecialItem finds inconsistent data"); int globalIndex = -1; if (!loading) { globalIndex = this.LeafIndexFromItem(item, index); } ChangeCounts(item, -1); ProtectedItems.RemoveAt(index); if (!loading) { OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item, globalIndex)); } }
internal int Remove(object item, bool returnLeafIndex) { int index = -1; int localIndex = ProtectedItems.IndexOf(item); if (localIndex >= 0) { if (returnLeafIndex) { index = LeafIndexFromItem(null, localIndex); } CollectionViewGroupInternal subGroup = item as CollectionViewGroupInternal; if (subGroup != null) { // Remove from the name to group map. RemoveSubgroupFromMap(subGroup); } ChangeCounts(item, -1); ProtectedItems.RemoveAt(localIndex); } return(index); }