Element
live The base class for all Fram3 UI descriptions. An Element is an immutable configuration object that describes a piece of user interface. Elements are lightweight and intended to be recreated on every build cycle. The framework uses elements as blueprints to create and update the actual rendered UI through the reconciliation process.
Constructor
Element
Creates a new element with an optional key.
| Parameter | Description |
|---|---|
key | An optional key to control reconciliation identity. When null, elements are matched by position and type only. |
Properties
Key
An optional key that controls how this element is matched against other elements during reconciliation. Elements with matching runtime types and keys are updated in place rather than replaced.
Methods
CanUpdate
Determines whether an existing element can be updated with a new element rather than being replaced. Two elements can be updated when they share the same runtime type and the same key.
| Parameter | Description |
|---|---|
oldElement | The existing element in the tree. |
newElement | The new element to compare against. |
Returns: True if the old element can be updated with the new element’s configuration.
GetChildren
Returns the children of this element for tree traversal. Override this in subclasses that contain child elements. The default implementation returns an empty collection.
Returns: The child elements of this element.
ShouldRebuild
Called by the framework before updating this element’s native representation when its parent rebuilds. Return false to skip repainting this element (its children will still be reconciled). Return true (the default) to repaint as normal. For this method is shadowed by its typed ShouldRebuild(StatelessElement, StatelessElement) override, which skips the entire subtree — not just the paint — when it returns false. For all other element types returning false skips only the ElementPainter.Paint call; children are still reconciled normally.
| Parameter | Description |
|---|---|
oldElement | The previous element description. |
newElement | The incoming element description from the parent. |
Returns: true to repaint; false to skip paint for this element.