Table of Contents

Class TwPickList<TItem>

Namespace
TwBlazor.Components
Assembly
TwBlazor.dll

Represents a dual list-box ("pick list") that moves items between a source and a target collection, with two-way binding on both lists plus optional up/down reordering within either one.

public class TwPickList<TItem> : TwBlazorComponentBase, IComponent, IHandleEvent, IHandleAfterRender, ITwComponent

Type Parameters

TItem

The type of items in both lists.

Inheritance
TwPickList<TItem>
Implements
Inherited Members

Remarks

Selection is tracked internally by value equality (EqualityComparer<T>), the same approach used by TwCheckboxGroup<TValue> - so items that compare equal are selected/deselected together. SelectedSourceItems and SelectedTargetItems only seed the initial selection (like Checked) rather than staying fully controlled, since re-syncing from the parameter on every render would immediately overwrite a click with a caller that isn't also echoing the corresponding Changed callback back in.

Constructors

TwPickList()

public TwPickList()

Properties

AllowReorder

Gets or sets whether each column shows up/down buttons for reordering its current selection.

[Parameter]
public bool AllowReorder { get; set; }

Property Value

bool

Disabled

Gets or sets whether the whole component is disabled.

[Parameter]
public bool Disabled { get; set; }

Property Value

bool

EmptyText

Gets or sets the text shown in place of a list that has no items. Defaults to the localized PickList_Empty text ("No items").

[Parameter]
public string? EmptyText { get; set; }

Property Value

string

SelectedSourceItems

Gets or sets the source list's initially selected items. Only read once, at first render - see the remarks on TwPickList<TItem>.

[Parameter]
public IEnumerable<TItem> SelectedSourceItems { get; set; }

Property Value

IEnumerable<TItem>

SelectedSourceItemsChanged

Gets or sets the callback invoked whenever the source list's selection changes.

[Parameter]
public EventCallback<IEnumerable<TItem>> SelectedSourceItemsChanged { get; set; }

Property Value

EventCallback<IEnumerable<TItem>>

SelectedTargetItems

Gets or sets the target list's initially selected items. Only read once, at first render - see the remarks on TwPickList<TItem>.

[Parameter]
public IEnumerable<TItem> SelectedTargetItems { get; set; }

Property Value

IEnumerable<TItem>

SelectedTargetItemsChanged

Gets or sets the callback invoked whenever the target list's selection changes.

[Parameter]
public EventCallback<IEnumerable<TItem>> SelectedTargetItemsChanged { get; set; }

Property Value

EventCallback<IEnumerable<TItem>>

ShowMoveAllButtons

Gets or sets whether the "move all" (double chevron) buttons are shown alongside the single-transfer chevron buttons.

[Parameter]
public bool ShowMoveAllButtons { get; set; }

Property Value

bool

SourceItems

Gets or sets the items available in the source (left) list.

[Parameter]
public IEnumerable<TItem> SourceItems { get; set; }

Property Value

IEnumerable<TItem>

SourceItemsChanged

Gets or sets the callback invoked when items move into or out of the source list, or are reordered within it.

[Parameter]
public EventCallback<IEnumerable<TItem>> SourceItemsChanged { get; set; }

Property Value

EventCallback<IEnumerable<TItem>>

SourceLabel

Gets or sets the heading shown above the source list. Defaults to the localized PickList_Source text ("Available").

[Parameter]
public string? SourceLabel { get; set; }

Property Value

string

TargetItems

Gets or sets the items in the target (right) list.

[Parameter]
public IEnumerable<TItem> TargetItems { get; set; }

Property Value

IEnumerable<TItem>

TargetItemsChanged

Gets or sets the callback invoked when items move into or out of the target list, or are reordered within it.

[Parameter]
public EventCallback<IEnumerable<TItem>> TargetItemsChanged { get; set; }

Property Value

EventCallback<IEnumerable<TItem>>

TargetLabel

Gets or sets the heading shown above the target list. Defaults to the localized PickList_Target text ("Selected").

[Parameter]
public string? TargetLabel { get; set; }

Property Value

string

TextField

Gets or sets the name of the property to display for each item.

[Parameter]
public string TextField { get; set; }

Property Value

string

Remarks

If null, empty, or not found on TItem, the item's ToString() is used.

Methods

BuildRenderTree(RenderTreeBuilder)

Renders the component to the supplied RenderTreeBuilder.

protected override void BuildRenderTree(RenderTreeBuilder __builder)

Parameters

__builder RenderTreeBuilder

OnAfterRenderAsync(bool)

Keeps each list a single Tab stop whose options are reached with the arrow keys, Home and End.

protected override Task OnAfterRenderAsync(bool firstRender)

Parameters

firstRender bool

Returns

Task

Remarks

Runs after every render because a transfer replaces the options, including whichever one held the Tab stop. The script attaches once per list and only re-syncs after that.

OnParametersSet()

Invoked when the component's parameters have been set. Ensures that the component has a unique identifier by generating one if none is provided.

protected override void OnParametersSet()

Remarks

If the component's identifier is not set, a unique ID is generated based on the component's type name (with a 'Tw' prefix removed if present) and a GUID. This helps ensure that each component instance can be uniquely identified, which is useful for scenarios such as associating labels with form elements or targeting elements in client-side scripts.