Table of Contents

Class UIElementCollection

Namespace
Icy.UI
Assembly
IcyUI.dll

Represents a collection of UIElement objects that can be observed for changes.

public class UIElementCollection : ObservableCollection<UIElement>, IList<UIElement>, ICollection<UIElement>, IReadOnlyList<UIElement>, IReadOnlyCollection<UIElement>, IEnumerable<UIElement>, IList, ICollection, IEnumerable, INotifyCollectionChanged, INotifyPropertyChanged
Inheritance
UIElementCollection
Implements
Inherited Members
Extension Methods

Remarks

An element has one parent: adding an element that already belongs to a parent, or is a root element of a Canvas, throws InvalidOperationException. Remove it from there first.

Methods

ClearItems()

Removes all items from the collection.

protected override void ClearItems()

InsertItem(int, UIElement)

Inserts a new UIElement into the collection at the specified index.

protected override void InsertItem(int index, UIElement item)

Parameters

index int

The zero-based index at which the new item should be inserted.

item UIElement

The UIElement to insert.

Exceptions

InvalidOperationException

item already belongs to a parent or a canvas.

RemoveItem(int)

Removes the UIElement at the specified index from the collection.

protected override void RemoveItem(int index)

Parameters

index int

The zero-based index of the element to remove.

SetItem(int, UIElement)

Replaces the UIElement at the specified index: removes the old one, then inserts item, raising the same events as RemoveItem(int) and InsertItem(int, UIElement).

protected override void SetItem(int index, UIElement item)

Parameters

index int

The zero-based index of the element to replace.

item UIElement

The new element.

Exceptions

InvalidOperationException

item already belongs to a parent or a canvas. The collection is left unchanged.

Events

ItemAdded

Occurs when a new UIElement is added to the collection.

public event DataEventHandler<UIElement>? ItemAdded

Event Type

DataEventHandler<UIElement>

ItemAdding

Occurs when a new UIElement is about to be added to the collection. This event can be used to cancel the addition.

public event CancellableEventHandler<UIElement>? ItemAdding

Event Type

CancellableEventHandler<UIElement>

ItemRemoved

Occurs when a UIElement is removed from the collection.

public event DataEventHandler<UIElement>? ItemRemoved

Event Type

DataEventHandler<UIElement>

ItemRemoving

Occurs when a UIElement is about to be removed from the collection. This event can be used to cancel the removal.

public event CancellableEventHandler<UIElement>? ItemRemoving

Event Type

CancellableEventHandler<UIElement>

Reset

Occurs when the collection has been cleared.

public event EventHandler? Reset

Event Type

EventHandler

Resetting

Occurs when the collection is about to be cleared. This event can be used to cancel the clearing operation.

public event CancelEventHandler? Resetting

Event Type

CancelEventHandler