ObservableStack
Description
ObservableStack is a container component that manages the display of its child components using a flexbox-inspired layout and an efficient reconciliation process. It leverages an observable list of components (each implementing an identifier and content hash) to update only those parts of the DOM that have changed, improving performance in dynamic interfaces. This component is part of the Collections group and is ideal for scenarios where the UI state, such as scroll position, must be maintained with minimal re-rendering.
Usage
Create an ObservableStack by supplying an ObservableList of components that implement IComponentWithID. The component can be configured for different orientations (vertical, horizontal, etc.) and debounced updates if needed.
API reference
public class ObservableStack : IComponent, IHasBackgroundColor, IHasMarginPadding, ISpecialCaseStyling, ICanWrapA Stack is a container-type component that abstracts the implementation of a flexbox in order to define the layout of its children components.
Constructors
Properties
public Orientation StackOrientation { get ; set ; }Gets or sets the stack orientation.
public bool CanWrap { get ; set ; }Gets or sets a value indicating whether the component's text can wrap onto multiple lines.
public bool IsInline { get ; set ; }Returns a value indicating whether the component is inline.
public HTMLElement InnerElement { get; private set; }Gets the underlying DOM element backing this component.
public string Background { get ; set ; }Gets or sets the CSS background of the component.
public string Margin { get ; set ; }Gets or sets the CSS margin of the component.
public string Padding { get ; set ; }Gets or sets the CSS padding of the component.
public HTMLElement StylingContainerGets or sets the styling container.
Methods
public ObservableStack AlignItems(ItemAlign align)Sets the align-items css property for this stack
Parameters
- align
public ObservableStack AlignItemsCenter()Sets the align-items css property for this stack to 'center'
Parameters
- align
public ObservableStack Relative()Make this stack relative (i.e. position:relative)
public ObservableStack AlignContent(ItemAlign align)Sets the align-content CSS property for this stack.
Parameters
- align
- The alignment.
Returns
The current instance.
public ObservableStack JustifyContent(ItemJustify justify)Sets the justify-content CSS property for this stack.
Parameters
- justify
- The justification.
Returns
The current instance.
public ObservableStack JustifyItems(ItemJustify justify)Sets the justify-items CSS property for this stack.
Parameters
- justify
- The justification.
Returns
The current instance.
public ObservableStack RemovePropagation()Removes the given propagation from the component.
public ObservableStack OnMouseOver(ComponentEventHandler<ObservableStack, Event> onMouseOver)Registers a callback invoked when the mouse over event fires.
public ObservableStack OnMouseOut(ComponentEventHandler<ObservableStack, Event> onMouseOut)Registers a callback invoked when the mouse out event fires.
public virtual HTMLElement Render()Renders the component's root HTML element.
public ObservableStack Horizontal()Configures the component to horizontal.
public ObservableStack Vertical()Configures the component to vertical.
public ObservableStack HorizontalReverse()Configures the horizontal reverse on the component.
public ObservableStack VerticalReverse()Configures the vertical reverse on the component.
public ObservableStack Wrap()Allows the component's content to wrap onto multiple lines.
public ObservableStack NoWrap()Removes / disables the wrap on the component.
public ObservableStack OverflowHidden()Hides any content that overflows the component's bounds.
public ObservableStack NoDefaultMargin()Removes / disables the default margin on the component.
public interface IComponentWithID : IComponentSamples
Basic ObservableStack Usage
The following sample demonstrates how to set up an ObservableStack, attach it to an observable list of components, and render it.