# SelectionModel

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-controls-repeater/selection/struct-selectionmodel/

**struct** · [`ferroui-controls-repeater`](/docs/0.5.0/api/ferroui-controls-repeater/) · v0.5.0

```rust
struct SelectionModel
```

The WinUI hierarchical selection model, independent of realized controls.

It defaults to multiple selection, can resolve arbitrary nested sources, represents group
selection as `Some(true)`, `Some(false)` or `None` (partial), and keeps selection synchronized
with source collection changes. Its tree is realized only as requested by selection operations.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L24)

## Members

- [`new`](#function-new)
- [`source`](#function-source)
- [`set_source`](#function-set_source)
- [`single_select`](#function-single_select)
- [`set_single_select`](#function-set_single_select)
- [`anchor_index`](#function-anchor_index)
- [`set_anchor_index`](#function-set_anchor_index)
- [`set_anchor_index_flat`](#function-set_anchor_index_flat)
- [`set_anchor_index_with_group`](#function-set_anchor_index_with_group)
- [`selected_index`](#function-selected_index)
- [`set_selected_index`](#function-set_selected_index)
- [`selected_item`](#function-selected_item)
- [`selected_indices`](#function-selected_indices)
- [`selected_items`](#function-selected_items)
- [`select`](#function-select)
- [`deselect`](#function-deselect)
- [`select_with_group`](#function-select_with_group)
- [`deselect_with_group`](#function-deselect_with_group)
- [`select_at`](#function-select_at)
- [`deselect_at`](#function-deselect_at)
- [`is_selected`](#function-is_selected)
- [`is_selected_with_group`](#function-is_selected_with_group)
- [`is_selected_at`](#function-is_selected_at)
- [`select_range_from_anchor`](#function-select_range_from_anchor)
- [`deselect_range_from_anchor`](#function-deselect_range_from_anchor)
- [`select_range_from_anchor_with_group`](#function-select_range_from_anchor_with_group)
- [`deselect_range_from_anchor_with_group`](#function-deselect_range_from_anchor_with_group)
- [`select_range_from_anchor_to`](#function-select_range_from_anchor_to)
- [`deselect_range_from_anchor_to`](#function-deselect_range_from_anchor_to)
- [`select_range`](#function-select_range)
- [`deselect_range`](#function-deselect_range)
- [`select_all`](#function-select_all)
- [`select_all_flat`](#function-select_all_flat)
- [`clear_selection`](#function-clear_selection)
- [`selection_changed`](#function-selection_changed)
- [`children_requested`](#function-children_requested)
- [`on_property_changed`](#function-on_property_changed)
- [`is_selection_invalidated_due_to_collection_change`](#function-is_selection_invalidated_due_to_collection_change)
- [`source_from_item`](#function-source_from_item)

<a id="function-new"></a>

### new

```rust
fn new() -> Rc<Self>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L38)

<a id="function-source"></a>

### source

```rust
fn source(self: &Self) -> Option<ItemsSource>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L47)

<a id="function-set_source"></a>

### set_source

```rust
fn set_source(self: &Self, source: Option<ItemsSource>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L48)

<a id="function-single_select"></a>

### single_select

```rust
fn single_select(self: &Self) -> bool
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L55)

<a id="function-set_single_select"></a>

### set_single_select

```rust
fn set_single_select(self: &Self, value: bool)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L56)

<a id="function-anchor_index"></a>

### anchor_index

```rust
fn anchor_index(self: &Self) -> Option<IndexPath>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L66)

<a id="function-set_anchor_index"></a>

### set_anchor_index

```rust
fn set_anchor_index(self: &Self, value: Option<IndexPath>) -> Result<(), SelectionError>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L80)

<a id="function-set_anchor_index_flat"></a>

### set_anchor_index_flat

```rust
fn set_anchor_index_flat(self: &Self, index: i32) -> Result<(), SelectionError>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L96)

<a id="function-set_anchor_index_with_group"></a>

### set_anchor_index_with_group

```rust
fn set_anchor_index_with_group(self: &Self, group: i32, item: i32) -> Result<(), SelectionError>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L99)

<a id="function-selected_index"></a>

### selected_index

```rust
fn selected_index(self: &Self) -> Option<IndexPath>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L102)

<a id="function-set_selected_index"></a>

### set_selected_index

```rust
fn set_selected_index(self: &Self, index: Option<IndexPath>) -> Result<(), SelectionError>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L106)

<a id="function-selected_item"></a>

### selected_item

```rust
fn selected_item(self: &Self) -> Option<BoxedValue>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L116)

<a id="function-selected_indices"></a>

### selected_indices

```rust
fn selected_indices(self: &Self) -> SelectedItems<IndexPath>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L120)

<a id="function-selected_items"></a>

### selected_items

```rust
fn selected_items(self: &Self) -> SelectedItems<Option<BoxedValue>>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L126)

<a id="function-select"></a>

### select

```rust
fn select(self: &Self, index: i32) -> Result<(), SelectionError>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L146)

<a id="function-deselect"></a>

### deselect

```rust
fn deselect(self: &Self, index: i32) -> Result<(), SelectionError>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L147)

<a id="function-select_with_group"></a>

### select_with_group

```rust
fn select_with_group(self: &Self, group: i32, item: i32) -> Result<(), SelectionError>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L148)

<a id="function-deselect_with_group"></a>

### deselect_with_group

```rust
fn deselect_with_group(self: &Self, group: i32, item: i32) -> Result<(), SelectionError>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L149)

<a id="function-select_at"></a>

### select_at

```rust
fn select_at(self: &Self, path: &IndexPath) -> Result<(), SelectionError>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L150)

<a id="function-deselect_at"></a>

### deselect_at

```rust
fn deselect_at(self: &Self, path: &IndexPath) -> Result<(), SelectionError>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L151)

<a id="function-is_selected"></a>

### is_selected

```rust
fn is_selected(self: &Self, index: i32) -> Option<bool>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L152)

<a id="function-is_selected_with_group"></a>

### is_selected_with_group

```rust
fn is_selected_with_group(self: &Self, group: i32, item: i32) -> Option<bool>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L153)

<a id="function-is_selected_at"></a>

### is_selected_at

```rust
fn is_selected_at(self: &Self, path: &IndexPath) -> Result<Option<bool>, SelectionError>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L156)

<a id="function-select_range_from_anchor"></a>

### select_range_from_anchor

```rust
fn select_range_from_anchor(self: &Self, index: i32) -> Result<(), SelectionError>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L160)

<a id="function-deselect_range_from_anchor"></a>

### deselect_range_from_anchor

```rust
fn deselect_range_from_anchor(self: &Self, index: i32) -> Result<(), SelectionError>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L161)

<a id="function-select_range_from_anchor_with_group"></a>

### select_range_from_anchor_with_group

```rust
fn select_range_from_anchor_with_group(self: &Self, group: i32, item: i32) -> Result<(), SelectionError>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L162)

<a id="function-deselect_range_from_anchor_with_group"></a>

### deselect_range_from_anchor_with_group

```rust
fn deselect_range_from_anchor_with_group(self: &Self, group: i32, item: i32) -> Result<(), SelectionError>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L163)

<a id="function-select_range_from_anchor_to"></a>

### select_range_from_anchor_to

```rust
fn select_range_from_anchor_to(self: &Self, index: &IndexPath) -> Result<(), SelectionError>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L164)

<a id="function-deselect_range_from_anchor_to"></a>

### deselect_range_from_anchor_to

```rust
fn deselect_range_from_anchor_to(self: &Self, index: &IndexPath) -> Result<(), SelectionError>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L168)

<a id="function-select_range"></a>

### select_range

```rust
fn select_range(self: &Self, start: &IndexPath, end: &IndexPath) -> Result<(), SelectionError>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L172)

<a id="function-deselect_range"></a>

### deselect_range

```rust
fn deselect_range(self: &Self, start: &IndexPath, end: &IndexPath) -> Result<(), SelectionError>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L173)

<a id="function-select_all"></a>

### select_all

```rust
fn select_all(self: &Self) -> Result<(), SelectionError>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L174)

<a id="function-select_all_flat"></a>

### select_all_flat

```rust
fn select_all_flat(self: &Self)
```

Selects a flat source as a single range without reading source items.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L180)

<a id="function-clear_selection"></a>

### clear_selection

```rust
fn clear_selection(self: &Self)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L184)

<a id="function-selection_changed"></a>

### selection_changed

```rust
fn selection_changed(self: &Self, handler: impl Fn(&SelectionModelSelectionChangedEventArgs) -> () + 'static) -> Rc<dyn IDisposable>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L185)

<a id="function-children_requested"></a>

### children_requested

```rust
fn children_requested(self: &Self, handler: impl Fn(&Rc<SelectionModelChildrenRequestedEventArgs>) -> () + 'static) -> Rc<dyn IDisposable>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L190)

<a id="function-on_property_changed"></a>

### on_property_changed

```rust
fn on_property_changed(self: &Self, property_name: &str)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L195)

<a id="function-is_selection_invalidated_due_to_collection_change"></a>

### is_selection_invalidated_due_to_collection_change

```rust
fn is_selection_invalidated_due_to_collection_change(self: &Self) -> bool
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L196)

<a id="function-source_from_item"></a>

### source_from_item

```rust
fn source_from_item(data: &BoxedValue) -> Option<ItemsSource>
```

Applies FerroUI's registered collection conversions when automatically resolving children.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls.Repeater/selection/selection_model.rs#L214)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToString`
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`
- [`MarkupTyped`](/docs/0.5.0/api/ferroui-base/metadata/trait-markuptyped/)
- [`INotifyPropertyChanged`](/docs/0.5.0/api/ferroui-base/data/model/use-inotifypropertychanged/)
- `PartialEq`
- `Display`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
