Skip to main content

Module items

Module items 

Source
Expand description

Lists: an ItemsHost keeps one template instance per item of an ItemsControl / ListView / ContentPresenter, reconciled by key, so an update only patches what changed. With a fixed item_height only the rows in (and near) view are built — the rest are two spacers.

Generated code drives it like this:

ⓘ
if let Some(mut it) = self.l0.begin(root, u) {
    for (index, item) in vm.visible().enumerate() {
        let selected = bind::is_selected(&sel, &item.id);
        let Some(row) = it.next(bind::key(&item.id), selected, __T0::build) else { continue };
        if let Some(v) = row.inst.b0.changed(bind::text(&item.name)) {
            if let Some(w) = row.w.get_path_mut(&[0]) { w.set_text(v.clone()); row.u.relayout(); }
        }
    }
    if let Some((w, u)) = it.finish(Some(__E0)) { /* empty-state bindings */ }
}

Structs§

Item
One item handed to the template’s bindings.
ItemsCursor
An update of an ItemsHost in progress.
ItemsHost
The instances of one list.

Constants§

SELECT
Action::slot of an item container: clicking it selects the item.