A combo box (dropdown) control that allows users to select an item from a list. Supports data binding, custom display formatting, and keyboard navigation.
Basic Usage
// Simple combo box with string itemsnewComboBox<string>().SetItemsSource(new[]{"Option 1","Option 2","Option 3"}).SetPlaceholder("Select an option...")// Combo box with custom objects and display functionnewComboBox<Person>().SetItemsSource(people).SetDisplayFunc(person=>person.Name).BindSelectedItem(nameof(vm.SelectedPerson),()=>vm.SelectedPerson,p=>vm.SelectedPerson=p)// Bound to observable collectionnewComboBox<Country>().BindItemsSource(nameof(vm.Countries),()=>vm.Countries).SetDisplayFunc(c=>$"{c.Flag}{c.Name}").BindSelectedItem(nameof(vm.SelectedCountry),()=>vm.SelectedCountry,c=>vm.SelectedCountry=c)
ComboBox has a default size of 200x40 pixels. The dropdown opens downward if space permits, otherwise upward. Keyboard navigation: Arrow keys to navigate, Enter/Space to select, Escape to close.
Layout Methods
Methods inherited from UiElement:
Method
Description
SetMargin(Margin)
Sets outer margin
BindMargin(name, getter)
Binds margin
SetHorizontalAlignment(HorizontalAlignment)
Sets horizontal alignment
BindHorizontalAlignment(name, getter)
Binds horizontal alignment
SetVerticalAlignment(VerticalAlignment)
Sets vertical alignment
BindVerticalAlignment(name, getter)
Binds vertical alignment
SetDesiredSize(Size)
Sets explicit size
BindDesiredSize(name, getter)
Binds size
SetDesiredWidth(float)
Sets explicit width
BindDesiredWidth(name, getter)
Binds width
SetDesiredHeight(float)
Sets explicit height
BindDesiredHeight(name, getter)
Binds height
Appearance Methods
Methods inherited from UiElement:
Method
Description
SetIsVisible(bool)
Shows/hides element
BindIsVisible(name, getter)
Binds visibility
SetOpacity(float)
Sets opacity 0.0-1.0 (default: 1.0)
BindOpacity(name, getter)
Binds opacity
SetBackground(IBackground)
Sets background (gradient, solid, etc.)
SetBackground(Color)
Sets solid color background
BindBackground(name, getter)
Binds background
SetCornerRadius(float)
Sets corner radius
BindCornerRadius(name, getter)
Binds corner radius
SetVisualOffset(Point)
Offsets visual position
BindVisualOffset(name, getter)
Binds visual offset
Shadow Methods
Methods inherited from UiElement:
Method
Description
SetShadowColor(Color)
Sets shadow color
BindShadowColor(name, getter)
Binds shadow color
SetShadowOffset(Point)
Sets shadow offset
BindShadowOffset(name, getter)
Binds shadow offset
SetShadowBlur(float)
Sets shadow blur radius
BindShadowBlur(name, getter)
Binds shadow blur
SetShadowSpread(float)
Sets shadow spread
BindShadowSpread(name, getter)
Binds shadow spread
Focus Methods
Methods inherited from UiElement:
Method
Description
SetTabIndex(int)
Sets tab order
BindTabIndex(name, getter)
Binds tab index
SetTabStop(bool)
Enables/disables tab stop (default: true)
BindTabStop(name, getter)
Binds tab stop
Accessibility Methods
Methods inherited from UiElement:
Method
Description
SetAccessibilityLabel(string?)
Sets screen reader label
BindAccessibilityLabel(name, getter)
Binds accessibility label
SetAccessibilityHint(string?)
Sets additional context hint
BindAccessibilityHint(name, getter)
Binds accessibility hint
SetAccessibilityValue(string?)
Sets current value description
BindAccessibilityValue(name, getter)
Binds accessibility value
SetAccessibilityTraits(AccessibilityTrait)
Sets accessibility traits
BindAccessibilityTraits(name, getter)
Binds accessibility traits
SetIsAccessibilityElement(bool)
Include in accessibility tree
ComboBox has AccessibilityRole.ComboBox by default. It automatically reports the selected value and Expanded/HasPopup traits.
newComboBox<string>().SetItemsSource(options).SetSelectedIndex(0)// Select first item.BindSelectedIndex(nameof(vm.SelectedIndex),()=>vm.SelectedIndex,i=>vm.SelectedIndex=i)
Observable Collection
// Items added/removed will automatically update the dropdownnewComboBox<TodoItem>().BindItemsSource(nameof(vm.TodoItems),()=>vm.TodoItems)// ObservableCollection<TodoItem>.SetDisplayFunc(item=>item.Title).BindSelectedItem(nameof(vm.SelectedTodo),()=>vm.SelectedTodo,t=>vm.SelectedTodo=t)