Widgets / ListView
ListView
A selectable, scrolling list. Highlights the selection and auto-scrolls to it.
Signature
ListView.view
(height: int)
(selStyle: Style)
(rowStyle: Style)
(selected: int)
(labels: string list)
: LayoutNode<'msg>
ListView.viewWith
(height: int) (selStyle: Style) (rowStyle: Style)
(isSelected: int -> bool) (scrollTo: int) (labels: string list)
: LayoutNode<'msg> Parameters
| parameter | type | what it is |
|---|---|---|
height | int | Visible rows. Only this many are built, whatever the list length. |
selStyle | Style | Style for the selected row (drawn full-width; use theme.selection). |
rowStyle | Style | Style for the other rows. |
selected | int | The selected index (your model owns it). |
labels | string list | The rows. Use viewWith with a predicate for multi-selection. |
Notes
Only the visible window of rows is built, so a million-row list costs the same as a ten-row one. The widget renders and highlights; the selection index and key handling live in your model. viewWith takes a predicate (for single or multi-select) plus a scrollTo row to keep in view.
Example
ListView.view 10 theme.selection theme.fg model.Selected
(model.Items |> List.map (fun i -> i.Name))