List Box
The list box displays items from an items source collection, on multiple lines, and allows individual or multiple selection.
The items in the list can be composed, bound and templated.
The list height expands to fit all the items unless set specifically (using the height attribute), or set by a containing control, such as the dock panel.
To learn more about the dock panel, see the reference page here.
When the height is constrained, and the total item height is larger, then the built-in scroll viewer in the list box will display a vertical scrollbar.
Similarly when the width of any item exceeds the width of the list box, then the built-in scroll viewer in the list box will display a horizontal scrollbar (unless prevented - see below).
Useful Properties
You will probably use these properties most often:
Property | Description |
---|---|
Items | |
SelectedIndex | The (zero-based) index of the selected item, or in the case of multiple selection the first selected item. |
SelectedItem | The selected item (object) from the items collection, or in the case of multiple selection the first selected item. |
SelectedItems | The selected items in a list. |
Selection | An ISelectionModel object with various methods to track multiple selected items. This is is optimized for a large items collection. |
SelectionMode | The mode of selection, see table below. |
| The horizontal scrollbar visibility for the built-in scroll viewer. Options are 'Disabled' (default), 'Auto', 'Hidden' and 'Visible'. When disabled, overflow is hidden. |
| The vertical scrollbar visibility for the built-in scroll viewer. Options are 'Disabled', 'Auto' (default), 'Hidden' and 'Visible'. When disabled, overflow is hidden. |
To optimize performance when the items collection is large, use of the ISelectionModel
is recommended.