ObservableStack
Description
ObservableStack<T> renders a list of items into a host Stack and keeps it in sync with an observable source. On every change it reconciles the DOM in place — only inserted, removed, or moved rows are touched — so scroll position and focus on the surrounding rows are preserved. This makes it suited to dynamic lists where re-rendering the whole stack would be wasteful or disruptive.
Usage
Create an ObservableStack<T> by supplying an IObservable<IReadOnlyList<T>> source and a renderItem delegate that builds a component for each item. ObservableList<T> implements that interface, so it can be passed directly; mutating the list (Add, RemoveAt, ReplaceAll, …) drives the reconciliation. An optional host Stack lets you control orientation and layout (defaults to a vertical Stack).
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.
- Namespace
- Tesserae
- Implements
- IComponent, IHasBackgroundColor, IHasMarginPadding, ISpecialCaseStyling, ICanWrap
Constructors
| Name | Description |
|---|---|
| ObservableStack | Initializes a new instance of this class. |
Properties
| Name | Description |
|---|---|
| StackOrientation | Gets or sets the stack orientation. |
| CanWrap | Gets or sets a value indicating whether the component's text can wrap onto multiple lines. |
| IsInline | Returns a value indicating whether the component is inline. |
| InnerElement | Gets the underlying DOM element backing this component. |
| Background | Gets or sets the CSS background of the component. |
| Margin | Gets or sets the CSS margin of the component. |
| Padding | Gets or sets the CSS padding of the component. |
| StylingContainer | Gets or sets the styling container. |
| PropagateToStackItemParent | Gets or sets the propagate to stack item parent. |
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
| Name | Description |
|---|---|
| AlignItems | Sets the align-items css property for this stack |
| AlignItemsCenter | Sets the align-items css property for this stack to 'center' |
| Relative | Make this stack relative (i.e. position:relative) |
| AlignContent | Sets the align-content CSS property for this stack. |
| JustifyContent | Sets the justify-content CSS property for this stack. |
| JustifyItems | Sets the justify-items CSS property for this stack. |
| RemovePropagation | Removes the given propagation from the component. |
| OnMouseOver | Registers a callback invoked when the mouse over event fires. |
| OnMouseOut | Registers a callback invoked when the mouse out event fires. |
| Clear | Clears the component's current state. |
| Render | Renders the component's root HTML element. |
| Horizontal | Configures the component to horizontal. |
| Vertical | Configures the component to vertical. |
| HorizontalReverse | Configures the horizontal reverse on the component. |
| VerticalReverse | Configures the vertical reverse on the component. |
| Wrap | Allows the component's content to wrap onto multiple lines. |
| Inline | Renders the component inline. |
| NoWrap | Removes / disables the wrap on the component. |
| OverflowHidden | Hides any content that overflows the component's bounds. |
| NoDefaultMargin | Removes / disables the default margin on the component. |
| Skeleton | Configures the component to skeleton. |
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 : IComponent- Namespace
- Tesserae
- Implements
- IComponent
Samples
Basic ObservableStack Usage
The following sample demonstrates how to set up an ObservableStack, attach it to an observable list of components, and render it.