ObservableCollectionEx

Ecng.ComponentModel

Represents an observable collection with extended methods, including range operations.

Implementiert: IListEx<T>, IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable, ICollectionEx<T>, IList, ICollection, INotifyCollectionChanged, INotifyPropertyChanged

Eigenschaften

Count
public int Count { get; }
value = observableCollectionEx.Count

Gets the number of elements contained in the collection.

IsReadOnly
public bool IsReadOnly { get; }
value = observableCollectionEx.IsReadOnly

Gets a value indicating whether the collection is read-only.

Item
public TItem Item { get; set; }
value = observableCollectionEx.Item
observableCollectionEx.Item = value

Gets or sets the element at the specified index.

index
The zero-based index of the element to get or set.

Rückgabe: The element at the specified index.

Methoden

Add
public virtual void Add(TItem item)
observableCollectionEx.Add(item)

Adds an item to the collection.

item
The item to add.
AddRange
public virtual void AddRange(IEnumerable<TItem> items)
observableCollectionEx.AddRange(items)

Adds a range of items to the collection.

items
The items to add.
Clear
public virtual void Clear()
observableCollectionEx.Clear()

Removes all items from the collection.

Contains
public bool Contains(TItem item)
result = observableCollectionEx.Contains(item)

Determines whether the collection contains a specific value.

item
The item to locate.

Rückgabe: true if the item is found; otherwise, false.

CopyTo
public void CopyTo(TItem[] array, int arrayIndex)
observableCollectionEx.CopyTo(array, arrayIndex)

Copies the elements of the collection to an array, starting at a particular index.

array
The destination array.
arrayIndex
The zero-based index at which copying begins.
GetEnumerator
public IEnumerator<TItem> GetEnumerator()
result = observableCollectionEx.GetEnumerator()

Returns an enumerator that iterates through the collection.

Rückgabe: An enumerator for the collection.

IndexOf
public int IndexOf(TItem item)
result = observableCollectionEx.IndexOf(item)

Determines the index of a specific item in the collection.

item
The item to locate.

Rückgabe: The index of the item if found; otherwise, -1.

Insert
public void Insert(int index, TItem item)
observableCollectionEx.Insert(index, item)

Inserts an item into the collection at the specified index.

index
The index at which the item should be inserted.
item
The item to insert.
OnCollectionChanged
private void OnCollectionChanged(NotifyCollectionChangedEventArgs args)
observableCollectionEx.OnCollectionChanged(args)

Raises the CollectionChanged event.

args
Details about the change.
OnCollectionReset
private void OnCollectionReset()
observableCollectionEx.OnCollectionReset()

Raises the CollectionChanged event with a reset action.

OnPropertyChanged
protected void OnPropertyChanged(string propertyName)
observableCollectionEx.OnPropertyChanged(propertyName)

Raises the PropertyChanged event.

propertyName
The name of the property that changed.
OnRemove
private void OnRemove(IList<TItem> items, int index)
observableCollectionEx.OnRemove(items, index)

Raises the collection changed event for a removal.

items
The items removed.
index
The index from which the items were removed.
ProcessCollectionChanged
protected virtual void ProcessCollectionChanged(IEnumerable<NotifyCollectionChangedEventHandler> subscribers, NotifyCollectionChangedEventArgs args)
observableCollectionEx.ProcessCollectionChanged(subscribers, args)

Processes the NotifyCollectionChangedEventHandler subscribers.

subscribers
The collection of subscribers.
args
Details about the change.
Remove
public virtual bool Remove(TItem item)
result = observableCollectionEx.Remove(item)

Removes the first occurrence of a specific item from the collection.

item
The item to remove.

Rückgabe: true if the item was successfully removed; otherwise, false.

RemoveAt
public void RemoveAt(int index)
observableCollectionEx.RemoveAt(index)

Removes the item at the specified index of the collection.

index
The zero-based index of the item to remove.
RemoveRange
public virtual void RemoveRange(IEnumerable<TItem> items)
observableCollectionEx.RemoveRange(items)

Removes a range of items from the collection.

items
The items to remove.
RemoveRange
public virtual int RemoveRange(int index, int count)
result = observableCollectionEx.RemoveRange(index, count)

Removes a specified range of items starting at a given index.

index
The starting index.
count
The number of items to remove.

Rückgabe: The number of removed items.

Ereignisse

AddedRange
public event Action<IEnumerable<TItem>> AddedRange
observableCollectionEx.AddedRange += handler

Occurs after a range of items has been added to the collection.

CollectionChanged
public event NotifyCollectionChangedEventHandler CollectionChanged
observableCollectionEx.CollectionChanged += handler

Occurs when the collection changes.

PropertyChanged
public event PropertyChangedEventHandler PropertyChanged
observableCollectionEx.PropertyChanged += handler

Occurs when a property value changes.

RemovedRange
public event Action<IEnumerable<TItem>> RemovedRange
observableCollectionEx.RemovedRange += handler

Occurs after a range of items has been removed from the collection.