CollectionChangedHandler<TItem, TCollection>

References
public abstract class CollectionChangedHandler<TItem, TCollection>
Class to help implement collection changed events on a data store
Remarks: This is used for the platform handler of controls that use collections. This class helps detect changes to a collection so that the appropriate action can be taken to update the UI with the changes. This is a simple helper that is much easier to implement than handling the INotifyCollectionChanged.CollectionChanged event directly.
TItemType of the items in the collection
TCollectionType of the collection where class

Properties

Collection

#
public TCollection Collection { get; protected set; }
Gets the collection that this handler is observing

Count

#
public abstract int Count { get; }
Gets the count of the items in the current registered collection.

Methods

AddItem

#
public abstract void AddItem(TItem item)
Adds the item to the end of the collection

AddRange

#
public virtual void AddRange(IEnumerable<TItem> items)
Adds multiple items to the end of the collection
Remarks: This simply calls AddItem(TItem) for each item in the list. If there is a faster mechanism for doing so, implementors should override this method. For example, sometimes adding a single item will update the UI for each item, this should be overridden so the UI is updated after all items have been added.
items (IEnumerable<TItem>)Enumeration of items to add to the end of the collection

BeginUpdates

#Since v2.9
protected virtual void BeginUpdates()
Called before any methods to change the collection have been called.
Remarks: There may be multiple methods called when the collection changes, such as RemoveRange then AddRange or RemoveItem then InsertItem. When this happens, some platforms may need to know all of the changes before refreshing the view. After all of the update methods, EndUpdates() is called to signal that they are done.
EndUpdates()

ElementAt

#
public virtual TItem ElementAt(int index)
Gets the element at the specified index of the current registered collection.
index (int)Index of the item to get.
The item at the specified index.

EndUpdates

#Since v2.9
protected virtual void EndUpdates()
Called after any methods to change the collection have been called.

IndexOf

#
public virtual int IndexOf(TItem item)
Gets the index of the specified item
item (TItem)Item to find the index of
Index of the item if contained in the collection, otherwise -1

InsertItem

#
public abstract void InsertItem(int index, TItem item)
Inserts an item at the specified index in the collection

InsertRange

#
public virtual void InsertRange(int index, IEnumerable<TItem> items)
Inserts multiple items to the specified index in the collection
Remarks: This simply calls InsertItem(int, TItem) for each item in the list. If there is a faster mechanism for doing so, implementors should override this method. For example, sometimes inserting a single item will update the UI for each item, this should be overridden so the UI is updated after all items have been inserted.
index (int)Index to start adding the items
items (IEnumerable<TItem>)Enumeration of items to add

InternalElementAt

#
protected abstract TItem InternalElementAt(int index)
Gets the element at the specified index.
Remarks: Derived classes should implement this to get the item at the specified index.
index (int)Index of the item to get.
The item at the specified index.

InternalIndexOf

#
protected abstract int InternalIndexOf(TItem item)
Gets the index of the item from the collection
Remarks: Derived classes should implement this to get the index of the item.
item (TItem)Item to find the index
index of the item in the collection, or -1 if the item is not found

OnRegisterCollection

#
protected virtual void OnRegisterCollection(EventArgs e)
Called when the object has been registered (attached) to a collection

OnUnregisterCollection

#
protected virtual void OnUnregisterCollection(EventArgs e)
Called when the object has unregistered the collection

Register

#
public virtual bool Register(TCollection collection)
Registers a specific collection to observe
collection (TCollection)collection to observe
true if the collection was registered, false otherwise

RemoveAllItems

#
public abstract void RemoveAllItems()
Removes all items from the collection

RemoveItem

#
public abstract void RemoveItem(int index)
Removes the item at the specified index

RemoveItem

#
public virtual void RemoveItem(TItem item)
Removes the specified item
Remarks: This will remove the item by finding the index and removing based on index. Implementors should override this method if there is a faster mechanism to do so.
item (TItem)Item to remove from the collection

RemoveRange

#
public virtual void RemoveRange(IEnumerable<TItem> items)
Removes the specified items from the collection
Remarks: This simply calls RemoveItem(TItem) for each item to remove. If there is a faster mechanism for doing so, implementors should override this method. For example, sometimes removing a single item will update the UI for each item, this should be overridden so the UI is updated after all items have been removed.
items (IEnumerable<TItem>)List of items to remove

RemoveRange

#
public virtual void RemoveRange(int index, int count)
Removes a specified count of items from the collection starting at the specified index
Remarks: This simply calls RemoveItem(int) for each item to remove. If there is a faster mechanism for doing so, implementors should override this method. For example, sometimes removing a single item will update the UI for each item, this should be overridden so the UI is updated after all items have been removed.
index (int)Index to start removing the items from
count (int)Number of items to remove

ReplaceItem

#Since v2.9
public virtual void ReplaceItem(int index, TItem newItem)
Replaces the item at the specified index
Remarks: This by default will remove then insert the item at the specified index.
index (int)Index of the item to replace
newItem (TItem)New item

ReplaceRange

#Since v2.9
public virtual void ReplaceRange(int index, IEnumerable<TItem> newItems)
Replaces a range of items starting at the specified index.
Remarks: By default this calls ReplaceItem(int, TItem) for each item.
index (int)Index of the start of the range
newItems (IEnumerable<TItem>)New items to replace the existing items at the same indexes

Reset

#
public virtual void Reset()
Resets the collection when it is dramatically changed
Remarks: By default this removes all items and adds all items back (if Collection is an IEnumerable{T}) Platform implementations can override this to do something more efficient if needed.

Unregister

#
public virtual void Unregister()
Unregisters the current registered collection