Skip to main content

RichTextElementCollection<T> Class

Definition​

Assembly:Avalonia.Controls.Documents
Package:Avalonia.Controls.Documents

A collection of child TextElements. Works both before and after document attachment.

public class RichTextElementCollection<T>

Inheritance: object -> RichTextElementCollection<T>

Implements: ICollection<>, IEnumerable<>, IList<>, IReadOnlyCollection<>, IReadOnlyList<>, IEnumerable, o

Constructors​

NameDescription
RichTextElementCollection<T>Creates a new collection for the specified owner.

RichTextElementCollection<T> Constructor​

Creates a new collection for the specified owner.

public RichTextElementCollection<T>(Avalonia.AvaloniaObject owner)

Parameters​

owner Avalonia.AvaloniaObject

Remarks​

Reach the collection through its owner rather than building one: an owner caches exactly one instance, and a second over the same owner splits pending content between them.

Methods​

NameDescription
AddAdds an element to the collection.
AddRangeNo summary available.
ClearClears all elements.
ContainsReturns whether the specified element is present in the collection.
CopyToCopies all elements to the specified array starting at arrayIndex.
FirstOrDefaultThe first element, or the type's default when the collection is empty.
FirstOrNullGets the first element, or null when the collection is empty.
GetEnumeratorReturns an enumerator that iterates over the elements in this collection.
IndexOfReturns the zero-based index of the specified element, or -1 if not found.
InsertInserts an element at the specified index.
LastOrDefaultThe last element, or the type's default when the collection is empty.
LastOrNullGets the last element, or null when the collection is empty.
RemoveRemoves an element from the collection.
RemoveAtRemoves the element at the specified index.

Add Method​

Adds an element to the collection.

public void Add(T item)

Parameters​

item T

AddRange Method​

public void AddRange(System.Collections.Generic.IEnumerable<T> items)

Parameters​

items System.Collections.Generic.IEnumerable<T>

Clear Method​

Clears all elements.

public void Clear()

Contains Method​

Returns whether the specified element is present in the collection.

public bool Contains(T item)

Parameters​

item T

Returns​

bool

CopyTo Method​

Copies all elements to the specified array starting at arrayIndex.

public void CopyTo(T[] array, int arrayIndex)

Parameters​

array T[]

arrayIndex int

FirstOrDefault Method​

The first element, or the type's default when the collection is empty.

public T FirstOrDefault()

Returns​

T

The first element, or .

FirstOrNull Method​

Gets the first element, or null when the collection is empty.

public T FirstOrNull()

Returns​

T

Remarks​

Named apart from the LINQ extension the collection also carries, so a reader can tell at the call site which one runs.

GetEnumerator Method​

Returns an enumerator that iterates over the elements in this collection.

public System.Collections.Generic.IEnumerator<T> GetEnumerator()

Returns​

System.Collections.Generic.IEnumerator<T>

IndexOf Method​

Returns the zero-based index of the specified element, or -1 if not found.

public int IndexOf(T item)

Parameters​

item T

Returns​

int

Insert Method​

Inserts an element at the specified index.

public void Insert(int index, T item)

Parameters​

index int

item T

LastOrDefault Method​

The last element, or the type's default when the collection is empty.

public T LastOrDefault()

Returns​

T

The last element, or .

LastOrNull Method​

Gets the last element, or null when the collection is empty.

public T LastOrNull()

Returns​

T

Remarks​

Named apart from the LINQ extension the collection also carries; see Avalonia.Controls.Documents.RichTextElementCollection<T>.FirstOrNull.

Remove Method​

Removes an element from the collection.

public bool Remove(T item)

Parameters​

item T

Returns​

bool

RemoveAt Method​

Removes the element at the specified index.

public void RemoveAt(int index)

Parameters​

index int

Properties​

NameDescription
CountGets the number of elements in the collection.
IsReadOnlyGets a value indicating whether this collection is read-only.
ItemNo summary available.

Count Property​

Gets the number of elements in the collection.

public int Count { get; set; }

IsReadOnly Property​

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

public bool IsReadOnly { get; set; }

Item Property​

public T Item { get; set; }