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
new Button(new Label("Click me"))
    .BindDisabled(ViewModel.IsProcessing)
    .BindVisible(ViewModel.ShowButton)
    .BindClassName("active", ViewModel.IsActive);

Advanced Styling

Elements support comprehensive styling through BaseElement:

// CSS styling and padding/margins
new TextField(ViewModel.UserInput)
    .StyleSheet("Styles/form-styles")
    .ClassName("input-field")
    .Padding(10)
    .Margin(5, 10, 5, 10);

// Conditional styling
new Label("Status")
    .BindClassName("error", ViewModel.HasError)
    .BindClassName("success", ViewModel.IsSuccess)
    .BindClassName("warning", ViewModel.HasWarning);

Event Handling

BaseElement provides event registration for all elements:

// Click events on any element
new Image("icons/help")
    .OnClick(_ => ViewModel.ShowHelp());

// Custom event registration
new CustomElement()
    .RegisterCallback<MouseEnterEvent>(_ => ViewModel.OnHover())
    .RegisterCallback<MouseLeaveEvent>(_ => ViewModel.OnLeave());

Properties

PropTypeDefault
name?
string
""
disabled?
bool
false
pickingMode?
PickingMode
PickingMode.Position
visible?
bool
true

Methods

PropTypeDefault
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.