pub struct ItemsViewSource { /* private fields */ }Expand description
What an ItemsView shows and what of it is selected: WinUI’s ItemsSource and the SelectionModel and current-element model that ItemsView keeps over it, as one object the application holds.
The application makes one with ItemsViewSource::new, giving the number of items, hands it to the ItemsView, and disposes it after the view. set_items is assigning a new ItemsSource: SelectionModel::Source(value) clears the selection and the anchor and raises SelectionChanged (controls/dev/Repeater/SelectionModel.cpp, 44), and ItemsView does it when it is given an ItemsSource (ItemsView.cpp, OnItemsSourceChanged, or OnItemsRepeaterItemsSourceChanged once its repeater exists). A selection taken after that, before the view is built, is kept, as WinUI’s is before Loaded; an index past the items is ignored, as SelectionNode::Select ignores it, and SelectionChanged raised all the same, as SelectionModel::SelectImpl raises it. Items added or removed in place (SelectionNode::OnSourceListChanged) are not ported: the application gives the new items with set_items.
Implementations§
Source§impl ItemsViewSource
impl ItemsViewSource
Sourcepub fn new(app: &mut App, item_count: usize) -> Ref<Self>
pub fn new(app: &mut App, item_count: usize) -> Ref<Self>
Creates a source of item_count items with nothing selected, for ItemsView’s default Single mode.
Sourcepub fn dispose(self: Handle<Self>, app: &mut App)
pub fn dispose(self: Handle<Self>, app: &mut App)
Releases the listeners; the selection is not used after.
Sourcepub fn selected_indices(self: Handle<Self>, app: &App) -> Vec<usize>
pub fn selected_indices(self: Handle<Self>, app: &App) -> Vec<usize>
The selected indices in ascending order: SelectedItems as positions.
Sourcepub fn selected_index(self: Handle<Self>, app: &App) -> Option<usize>
pub fn selected_index(self: Handle<Self>, app: &App) -> Option<usize>
SelectedItem as a position: the first selected index.
Sourcepub fn select_all(self: Handle<Self>, app: &mut App)
pub fn select_all(self: Handle<Self>, app: &mut App)
SelectAll (SelectAllFlat): every item, whatever the mode, as WinUI’s model does.
Sourcepub fn deselect_all(self: Handle<Self>, app: &mut App)
pub fn deselect_all(self: Handle<Self>, app: &mut App)
DeselectAll.
Sourcepub fn invert_selection(self: Handle<Self>, app: &mut App)
pub fn invert_selection(self: Handle<Self>, app: &mut App)
InvertSelection: the selected items become unselected and the others selected.
Sourcepub fn item_count(self: Handle<Self>, app: &App) -> usize
pub fn item_count(self: Handle<Self>, app: &App) -> usize
The number of items: ItemsSource’s count.
Trait Implementations§
Source§impl ChangeNotifier for ItemsViewSource
impl ChangeNotifier for ItemsViewSource
fn change_notifier_data(&self) -> &ChangeNotifierData
fn change_notifier_data_mut(&mut self) -> &mut ChangeNotifierData
Source§fn will_add_listener(self: Handle<Self>, app: &mut App)
fn will_add_listener(self: Handle<Self>, app: &mut App)
addListener that
work before super.addListener go here.Source§fn did_remove_listener(self: Handle<Self>, app: &mut App)
fn did_remove_listener(self: Handle<Self>, app: &mut App)
removeListener that
work after super.removeListener go here.