ListBox Class
NuGet: GHIElectronics.TinyCLR.UI
Assembly: GHIElectronics.TinyCLR.UI
Namespace: GHIElectronics.TinyCLR.UI.Controls
A scrollable list of selectable items. Two content modes: Items — add explicit ListBoxItem rows via Items (fully realized). ItemsSource — bind a large IList of data to ItemsSource; the list then virtualizes, recycling a small pool of rows (each item shown via ToString()). This replaces the former separate VirtualizingListBox. The two modes are mutually exclusive; setting ItemsSource switches the list into virtualized mode.
public class ListBox : ContentControl
Constructors
ListBox()
public ListBox()
Creates a new ListBox.
Properties
Items
public ListBoxItemCollection Items { get; }
The collection of items in the list.
SelectedIndex
public int SelectedIndex { get; set; }
Index of the selected item, or -1 if none is selected.
SelectedItem
public ListBoxItem SelectedItem { get; set; }
The currently selected item, or null if none is selected.
HorizontalOffset
public int HorizontalOffset { get; set; }
Horizontal offset of the scroll.
VerticalOffset
public int VerticalOffset { get; set; }
Vertical offset of the scroll.
ExtentHeight
public int ExtentHeight { get; }
Extent height of the scroll area.
ExtentWidth
public int ExtentWidth { get; }
Extent width of the scroll area.
ScrollingStyle
public ScrollingStyle ScrollingStyle { get; set; }
The scrolling style.
ItemsSource
public IList ItemsSource { get; set; }
Binds a large data list to the list box; each item is shown via its ToString(). Setting this switches the list into virtualized mode (a small pool of rows is recycled while scrolling), for big lists that would be too heavy as explicit Items. Leave null to use the Items collection. This replaces the former separate VirtualizingListBox control.
ItemHeight
public int ItemHeight { get; set; }
Fixed row height in pixels used for the virtualization math in ItemsSource mode.
Methods
ScrollIntoView(ListBoxItem item)
public void ScrollIntoView(ListBoxItem item)
Scrolls the list so the given item is visible.
OnButtonDown(GHIElectronics.TinyCLR.UI.Input.ButtonEventArgs e)
protected override void OnButtonDown(GHIElectronics.TinyCLR.UI.Input.ButtonEventArgs e)
Handles Up/Down navigation and Select activation via hardware buttons.
Events
Click
public event RoutedEventHandler Click
Fires when the user commits the current selection — either by tapping a ListBoxItem or by pressing HardwareButton.Select while the ListBox has focus. The event source is the committed ListBoxItem.
SelectionChanged
public event SelectionChangedEventHandler SelectionChanged
Raised when the selected item changes.
ScrollChanged
public event ScrollChangedEventHandler ScrollChanged
Event handler if the scroll changes.