UI Toolbox logoUI Toolbox

Choice items

A ChoiceItem (in UIToolbox) is one choice: Text, Detail, Icon, Group, Enabled and InsertText (for an AutoCompleteField). A string converts to a ChoiceItem with only the text. The same list of items can fill a SearchDropdown and a context menu:

var commands = new List<ChoiceItem>
{
    new("New", "Ctrl+N", group: "File"),
    new("Print", "Ctrl+P", group: "File", enabled: false),
    new("Undo", "Ctrl+Z", group: "Edit")
};
search.Items = commands;

var menu = new ContextMenuComponent();
menu.AddItems(commands, item => run(item.Text));