VegaRise.NET
HomeAPI Reference
Back to DOM

ParentElementClass

Definition

Namespace
DOM.Abstracts
Assembly
DOM.dll

Parent element that can contain child elements and provides child management helpers.

Remarks

is the base class for every DOM element that can contain other elements (sections, paragraphs, tables, headers/footers, etc.). It manages an ordered collection, keeps each child's parent reference up to date, and provides insert / remove / query helpers. ParentElement Children Most user-facing container APIs (,,, and so on) are implemented in the subclass, but they all build on the primitive operations provided here. AddParagraph AddImage AddTable ElementsContainer

Examples

csharp
1// 1. Create a parent with initial children
2var parent = new ParentElement(new Paragraph(), new Paragraph());
3
csharp
1// 2. Add children after construction
2parent.AddChild(new Paragraph());
3
csharp
1// 3. Query descendants of a given type
2var paragraphs = parent.Elements<Paragraph>();
3
csharp
1// 4. Insert a child at a specific index
2parent.InsertChildToIndex(0, new Paragraph());
3
csharp
1// 5. Remove a specific child or all children
2parent.RemoveChildren(paragraph);
3parent.RemoveAllChildren();
4
csharp
1// 6. Dump the object tree for debugging
2string tree = parent.LogObjectTree();
3

Constructors

ParentElement()

Initializes an empty with no children. ParentElement

ParentElement(IElement[] children)

Initializes a with the specified children. ParentElement

Properties

ChildrenIElement

Gets or sets the ordered collection of direct child elements.

Methods

Adds one or more child elements to the end of the children collection.

Recursively enumerates all descendants of type . T

Gets the child of type at the specified index among children of that type. T

Inserts the specified elements immediately after . sourceElement

Inserts the specified elements immediately before . sourceElement

Inserts one or more child elements at the specified index.

Produces a debug-friendly, indented representation of the object tree rooted at this element.

Removes all direct children from this element.

Removes the specified children from this element.