Class SelectionState<TValue>
- Namespace
- BlazOrbit.Abstractions
- Assembly
- BlazOrbit.Core.dll
Tracks the selected value(s) for a selection-capable component, supporting both single and multiple modes inferred from TValue.
public sealed class SelectionState<TValue>
Type Parameters
TValue
- Inheritance
-
objectSelectionState<TValue>
Constructors
SelectionState()
Creates a new state with the default value-equality comparer.
public SelectionState()
SelectionState(IEqualityComparer<object>)
Creates a new state with a custom equality comparer for selection items.
public SelectionState(IEqualityComparer<object> comparer)
Parameters
comparerIEqualityComparer<object>
Properties
Count
Number of currently selected items.
public int Count { get; }
Property Value
- int
ElementType
Element type of the selection (the inner type when TValue is a collection).
public Type ElementType { get; }
Property Value
- Type
IsMultiple
True when TValue represents a multi-selection (collection) value.
public bool IsMultiple { get; }
Property Value
- bool
SelectedValues
Snapshot of the currently selected values.
public IReadOnlyCollection<object> SelectedValues { get; }
Property Value
- IReadOnlyCollection<object>
Methods
Clear()
Clears all selected values and raises StateChanged.
public void Clear()
Deselect(object?)
Removes a value from the selection. No-op when value is null.
public void Deselect(object? value)
Parameters
valueobject
GetValue()
Materializes the selection as a value of TValue.
public TValue GetValue()
Returns
- TValue
IsSelected(object?)
Returns whether value is part of the current selection.
public bool IsSelected(object? value)
Parameters
valueobject
Returns
- bool
Select(object?)
Adds value to the selection (replacing the previous value in single mode).
public void Select(object? value)
Parameters
valueobject
SelectAll(IEnumerable<object?>)
Adds every non-null entry of values to the selection. No-op in single mode.
public void SelectAll(IEnumerable<object?> values)
Parameters
valuesIEnumerable<object>
SetSingleValue(object?)
Replaces the selection with a single value (or clears it when null), regardless of mode.
public void SetSingleValue(object? value)
Parameters
valueobject
SetValue(TValue?)
Replaces the selection from a TValue instance.
public void SetValue(TValue? value)
Parameters
valueTValue
Toggle(object?)
Adds or removes value based on its current selection state.
public void Toggle(object? value)
Parameters
valueobject
Events
StateChanged
Raised whenever the set of selected values changes.
public event Action? StateChanged
Event Type
- Action