Class BindingTrackingList<T>
Provides component model binding over a tracking list.
public class BindingTrackingList<T> : TrackingList<T>, IList<T>, ICollection<T>, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IBindingList, ITypedList, ICancelAddNew, IList, ICollection, IEnumerable
Type Parameters
T
- Inheritance
-
TrackingList<T>BindingTrackingList<T>
- Implements
-
IList<T>ICollection<T>IEnumerable<T>
- Inherited Members
- Extension Methods
Constructors
BindingTrackingList(IEnumerable<T>, int, IEqualityComparer<T>?, ITrackingListContext<T>?)
Creates a binding tracking list with baseline items.
public BindingTrackingList(IEnumerable<T> items, int initialCapacity = 0, IEqualityComparer<T>? comparer = null, ITrackingListContext<T>? context = null)
Parameters
itemsIEnumerable<T>initialCapacityintcomparerIEqualityComparer<T>contextITrackingListContext<T>
BindingTrackingList(int, IEqualityComparer<T>?, ITrackingListContext<T>?)
Creates an empty binding tracking list.
public BindingTrackingList(int capacity = 0, IEqualityComparer<T>? comparer = null, ITrackingListContext<T>? context = null)
Parameters
capacityintcomparerIEqualityComparer<T>contextITrackingListContext<T>
Properties
AllowEdit
Gets whether you can update items in the list.
public bool AllowEdit { get; }
Property Value
AllowNew
Gets whether you can add items to the list using AddNew().
public bool AllowNew { get; }
Property Value
AllowRemove
Gets whether you can remove items from the list, using Remove(object) or RemoveAt(int).
public bool AllowRemove { get; }
Property Value
IsSorted
Gets whether the items in the list are sorted.
public bool IsSorted { get; }
Property Value
- bool
true if ApplySort(PropertyDescriptor, ListSortDirection) has been called and RemoveSort() has not been called; otherwise, false.
Exceptions
this[int]
Gets or sets the element at the specified index.
public override T this[int index] { get; set; }
Parameters
indexintThe zero-based index of the element to get or set.
Property Value
- T
The element at the specified index.
Exceptions
- ArgumentOutOfRangeException
indexis not a valid index in the IList<T>.- NotSupportedException
The property is set and the IList<T> is read-only.
SortDirection
Gets the direction of the sort.
public ListSortDirection SortDirection { get; }
Property Value
- ListSortDirection
One of the ListSortDirection values.
Exceptions
SortProperty
Gets the PropertyDescriptor that is being used for sorting.
public PropertyDescriptor? SortProperty { get; }
Property Value
- PropertyDescriptor
The PropertyDescriptor that is being used for sorting.
Exceptions
SupportsChangeNotification
Gets whether a ListChanged event is raised when the list changes or an item in the list changes.
public bool SupportsChangeNotification { get; }
Property Value
- bool
true if a ListChanged event is raised when the list changes or when an item changes; otherwise, false.
SupportsSearching
Gets whether the list supports searching using the Find(PropertyDescriptor, object) method.
public bool SupportsSearching { get; }
Property Value
- bool
true if the list supports searching using the Find(PropertyDescriptor, object) method; otherwise, false.
SupportsSorting
Gets whether the list supports sorting.
public bool SupportsSorting { get; }
Property Value
Methods
Add(T)
Adds an item to the ICollection<T>.
public override void Add(T item)
Parameters
itemTThe object to add to the ICollection<T>.
Exceptions
- NotSupportedException
The ICollection<T> is read-only.
AddNew()
Creates and adds a new item.
public override T AddNew()
Returns
- T
CancelNew(int)
Discards a pending new item from the collection.
public void CancelNew(int itemIndex)
Parameters
itemIndexintThe index of the item that was previously added to the collection.
Clear()
Removes all items from the ICollection<T>.
public override void Clear()
Exceptions
- NotSupportedException
The ICollection<T> is read-only.
Configure(PropertyDescriptorCollection, string?)
Sets the properties and name exposed through typed list access.
public void Configure(PropertyDescriptorCollection properties, string? listName = null)
Parameters
propertiesPropertyDescriptorCollectionlistNamestring
EndNew(int)
Commits a pending new item to the collection.
public void EndNew(int itemIndex)
Parameters
itemIndexintThe index of the item that was previously added to the collection.
Insert(int, T)
Inserts an item to the IList<T> at the specified index.
public override void Insert(int index, T item)
Parameters
indexintThe zero-based index at which
itemshould be inserted.itemTThe object to insert into the IList<T>.
Exceptions
- ArgumentOutOfRangeException
indexis not a valid index in the IList<T>.- NotSupportedException
The IList<T> is read-only.
OnChanged(TrackingListChange<T>)
Handles a structural change.
protected override void OnChanged(TrackingListChange<T> change)
Parameters
changeTrackingListChange<T>
OnConfirmed(TrackingListConfirmationKind, int, T)
Handles a confirmed operation.
protected override void OnConfirmed(TrackingListConfirmationKind kind, int index, T item)
Parameters
kindTrackingListConfirmationKindindexintitemT
Remove(T)
Removes the first occurrence of a specific object from the ICollection<T>.
public override bool Remove(T item)
Parameters
itemTThe object to remove from the ICollection<T>.
Returns
- bool
true if
itemwas successfully removed from the ICollection<T>; otherwise, false. This method also returns false ifitemis not found in the original ICollection<T>.
Exceptions
- NotSupportedException
The ICollection<T> is read-only.
RemoveAt(int)
Removes the IList<T> item at the specified index.
public override void RemoveAt(int index)
Parameters
indexintThe zero-based index of the item to remove.
Exceptions
- ArgumentOutOfRangeException
indexis not a valid index in the IList<T>.- NotSupportedException
The IList<T> is read-only.
Events
AddingNew
public event AddingNewEventHandler? AddingNew
Event Type
ListChanged
Occurs when the list changes or an item in the list changes.
public event ListChangedEventHandler? ListChanged