Elements
BaseElement
The abstract base class that all ELEMENTS components inherit from. Provides core functionality for styling, events, lifecycle management, and property binding.
Constructor
BaseElement is an abstract class and cannot be instantiated directly. It is inherited by all other elements.
Examples
Basic Property Usage
All elements inherit these core BaseElement features:
// Basic styling and state
new Label("Hello World")
.ClassName("my-label")
.Disabled(false)
.Visible(true);
// Reactive property binding
var IsProcessing = new ReactiveProperty<bool>(false);
var ShowButton = new ReactiveProperty<bool>(true);
var IsActive = new ReactiveProperty<bool>(false);
new Button(new Label("Click me"))
.BindDisabled(IsProcessing)
.BindVisible(ShowButton)
.BindClassName("active", IsActive);Advanced Styling
Elements support comprehensive styling through BaseElement:
// CSS styling and padding/margins
var UserInput = new ReactiveProperty<string>("");
new TextField(UserInput)
.StyleSheet("Styles/form-styles")
.ClassName("input-field")
.Padding(10)
.Margin(5, 10, 5, 10);
// Conditional styling
var HasError = new ReactiveProperty<bool>(false);
var IsSuccess = new ReactiveProperty<bool>(false);
var HasWarning = new ReactiveProperty<bool>(false);
new Label("Status")
.BindClassName("error", HasError)
.BindClassName("success", IsSuccess)
.BindClassName("warning", HasWarning);Event Handling
BaseElement provides event registration for all elements:
// Click events on any element
new Image("icons/help")
.OnClick(_ => ShowHelp());
// Custom event registration
new Label("Hover me")
.RegisterCallback<MouseEnterEvent>(_ => OnHover())
.RegisterCallback<MouseLeaveEvent>(_ => OnLeave());Properties
| Prop | Type | Default |
|---|---|---|
name? | string | "" |
disabled? | bool | false |
pickingMode? | PickingMode | PickingMode.Position |
visible? | bool | true |
Methods
| Prop | Type | Default |
|---|---|---|
Name? | (string) => T | - |
GetName? | () => string | - |
BindName? | (Observable<string>) => T | - |
Disabled? | (bool = true) => T | - |
GetDisabled? | () => bool | - |
BindDisabled? | (Observable<bool>) => T | - |
PickingMode? | (PickingMode) => T | - |
GetPickingMode? | () => PickingMode | - |
BindPickingMode? | (Observable<PickingMode>) => T | - |
Visible? | (bool) => T | - |
GetVisible? | () => bool | - |
BindVisible? | (Observable<bool>) => T | - |
StyleSheet? | (StyleSheet) => T or (string) => T | - |
ClassName? | (string, bool = true) => T | - |
HasClassName? | (string) => bool | - |
BindClassName? | (string, Observable<bool>) => T | - |
Padding? | (int) => T or (int, int, int, int) => T | - |
PaddingVertical? | (int) => T | - |
PaddingHorizontal? | (int) => T | - |
Margin? | (int) => T or (int, int, int, int) => T | - |
MarginVertical? | (int) => T | - |
MarginHorizontal? | (int) => T | - |
RegisterCallback? | <TEvent>(EventCallback<TEvent>) => T | - |
OnClick? | (EventCallback<ClickEvent>) => T | - |
Ref? | (ref T) => T | - |
Dispose? | () => void | - |
BuildVisualElement? | () => VisualElement | - |
BaseElement is the root class for all ELEMENTS components.