StatePanelWidget
Namespace: Hex1b.Widgets
Assembly: Hex1b.dll
A widget that provides identity-anchored scope for its child subtree. The state object's reference identity determines which node is reused across reconciliation frames, enabling state preservation across list reorders.
public sealed record StatePanelWidget : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<StatePanelWidget>Inheritance
Object → Hex1bWidget → StatePanelWidget
Implements
Constructors
StatePanelWidget(object, Func<StatePanelContext, Hex1bWidget>)
A widget that provides identity-anchored scope for its child subtree. The state object's reference identity determines which node is reused across reconciliation frames, enabling state preservation across list reorders.
Parameters:
StateKey(Object):Builder(Func<StatePanelContext, Hex1bWidget>):
public StatePanelWidget(object StateKey, Func<StatePanelContext, Hex1bWidget> Builder)Properties
Builder
Returns: Func<StatePanelContext, Hex1bWidget>
public Func<StatePanelContext, Hex1bWidget> Builder { get; init; }StateKey
Returns: Object
public object StateKey { get; init; }Remarks
The builder is deferred to reconciliation time (like ), so the has access to the resolved node's current state.
When nested under another StatePanelNode, identity resolution uses the ancestor's registry dictionary keyed by reference equality. Without an ancestor, falls back to positional matching with a state key reference check.
Important: The StateKey is compared by reference identity (). Use a stable reference-type object (e.g., a view model instance). Value types and freshly-boxed objects will not match across frames.
Examples
ctx.StatePanel(myViewModel, sp =>
sp.Text($"Count: {myViewModel.Count}")
);