Picker
Description
Picker is a versatile UI component used for selecting items from a list of suggestions. It provides support for both multi-selection (with tag-like selections) and single selection modes, and it can render selected items either inline or as separate components. This component is useful when you need to allow users to search, filter, and pick recipients or tags with confirmation feedback via suggestions.
Usage
You instantiate a Picker using the static helper method from Tesserae.UI. The component is generic (Picker
Below is a simple example demonstrating how to create a picker with text suggestions:
Methods
Items(params TPickerItem[] items)
- Description: Sets the list of available picker items using a parameter array.
- Parameters: An array of TPickerItem.
- Returns: The current Picker instance for fluent chaining.
Items(IEnumerable
items) - Description: Sets the list of available picker items from an enumerable collection.
- Parameters: An IEnumerable of TPickerItem.
- Returns: The current Picker instance for fluent chaining.
OnItemSelected(ComponentEventHandler<Picker
, ItemPickedEvent> eventHandler) - Description: Registers an event handler that is invoked whenever an item is picked/selected.
- Parameters: A delegate with parameters (sender: Picker
, e: ItemPickedEvent). - Returns: The current Picker instance for fluent chaining.
Properties
TabIndex (set)
- Description: Sets the tab index of the underlying text input control.
MaximumAllowedSelections
- Description: Gets the maximum number of items that can be selected.
DuplicateSelectionsAllowed
- Description: Indicates whether the same item can be selected more than once.
SuggestionsTolerance
- Description: Determines the minimum number of characters in the textbox before suggestions appear.
PickerItems (read-only)
- Description: Returns an enumerable list of all available picker items.
SelectedPickerItems (read-only)
- Description: Returns an enumerable list of currently selected items.
UnselectedPickerItems (read-only)
- Description: Returns an enumerable list of items that have not been selected.
Samples
Basic Picker with Text Suggestions
In this sample, we create a picker that supports multiple selections. We add a few sample items and register an event handler to log the selected item to the console.
Picker with Inline Selections and Component-based Rendering
This sample demonstrates a picker that renders selected items using an icon alongside text for a richer UI experience.