ConvertibleObservableCollection

Ecng.ComponentModel

Collection which maps items to another type to display.

继承自: BaseObservableCollection

实现: IConvertibleObservableCollection<T>, IListEx<T>, IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable, ICollectionEx<T>

构造函数

ConvertibleObservableCollection
public ConvertibleObservableCollection(ICollection<TDisplay> collection, Func<TItem, TDisplay> converter)
convertibleObservableCollection = ConvertibleObservableCollection(collection, converter)

Collection which maps items to another type to display.

属性

Count
public override int Count { get; }
value = convertibleObservableCollection.Count

Gets the number of elements contained in the ICollection.

返回值: The number of elements contained in the ICollection.

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

Gets or sets the element at the specified index.

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

返回值: The element at the specified index.

Items
public TItem[] Items { get; }
value = convertibleObservableCollection.Items

Gets all original items in the collection.

System#Collections#Generic#ICollection{TItem}#IsReadOnly

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

返回值: true if the ICollection is read-only; otherwise, false.

方法

Add
public void Add(TItem item)
convertibleObservableCollection.Add(item)

Adds an item to the ICollection.

item
The object to add to the ICollection.
AddRange
public void AddRange(IEnumerable<TItem> items)
convertibleObservableCollection.AddRange(items)

Adds a range of items to the collection.

items
Items to add.
Clear
public void Clear()
convertibleObservableCollection.Clear()

Removes all items from the collection.

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

Determines whether the ICollection contains a specific value.

item
The object to locate in the ICollection.

返回值: true if is found in the ICollection; otherwise, false.

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

Copies the elements of the ICollection to an Array, starting at a particular Array index.

array
The one-dimensional Array that is the destination of the elements copied from ICollection. The Array must have zero-based indexing.
arrayIndex
The zero-based index in at which copying begins.
GetEnumerator
public IEnumerator<TItem> GetEnumerator()
result = convertibleObservableCollection.GetEnumerator()

Returns an enumerator that iterates through the collection.

返回值: A IEnumerator that can be used to iterate through the collection.

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

Determines the index of a specific item in the IList.

item
The object to locate in the IList.

返回值: The index of if found in the list; otherwise, -1.

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

Inserts an item to the IList at the specified index.

index
The zero-based index at which should be inserted.
item
The object to insert into the IList.
Remove
public bool Remove(TItem item)
result = convertibleObservableCollection.Remove(item)

Removes the first occurrence of a specific object from the ICollection.

item
The object to remove from the ICollection.

返回值: true if was successfully removed from the ICollection; otherwise, false. This method also returns false if is not found in the original ICollection.

RemoveAll
public void RemoveAll(Func<TItem, bool> pred)
convertibleObservableCollection.RemoveAll(pred)

Remove items for which returns true.

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

Removes the IList item at the specified index.

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

Removes a range of items from the collection.

items
Items to remove.
RemoveRange
public override int RemoveRange(int index, int count)
result = convertibleObservableCollection.RemoveRange(index, count)

Removes a range of items starting at the specified index.

index
Starting index.
count
Number of items to remove.

返回值: Number of items removed.

System#Collections#IEnumerable#GetEnumerator()

Returns an enumerator that iterates through a collection.

返回值: An IEnumerator object that can be used to iterate through the collection.

TryGet
public TDisplay TryGet(TItem item)
result = convertibleObservableCollection.TryGet(item)

Get display item by item.

事件

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

Occurs when a range of items is added to the collection.

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

Occurs when a range of items is removed from the collection.