# ItemsSourceView

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-controls/struct-itemssourceview/

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

```rust
struct ItemsSourceView
```

Represents a standardized view of the supported interactions between an
items collection and an items control.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/items_source_view.rs#L21)

## Members

- [`empty`](#function-empty)
- [`new`](#function-new)
- [`count`](#function-count)
- [`has_key_index_mapping`](#function-has_key_index_mapping)
- [`key_from_index`](#function-key_from_index)
- [`index_from_key`](#function-index_from_key)
- [`source`](#function-source)
- [`add_collection_changed`](#function-add_collection_changed)
- [`remove_collection_changed`](#function-remove_collection_changed)
- [`get_at`](#function-get_at)
- [`contains`](#function-contains)
- [`index_of`](#function-index_of)
- [`get_or_create`](#function-get_or_create)
- [`get_or_create_of`](#function-get_or_create_of)
- [`iter`](#function-iter)
- [`to_vec`](#function-to_vec)

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

### empty

```rust
fn empty() -> Rc<ItemsSourceView>
```

Gets an empty `ItemsSourceView`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/items_source_view.rs#L39)

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

### new

```rust
fn new(source: ItemsSource) -> Rc<Self>
```

Initializes a new instance of the view for the specified data source.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/items_source_view.rs#L51)

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

### count

```rust
fn count(self: &Self) -> usize
```

Gets the number of items in the collection.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/items_source_view.rs#L64)

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

### has_key_index_mapping

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

Gets a value that indicates whether the items source can provide a unique key for
each item: whether the source implements `IKeyIndexMapping`
(WinUI `ItemsSourceView.HasKeyIndexMapping`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/items_source_view.rs#L73)

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

### key_from_index

```rust
fn key_from_index(self: &Self, index: i32) -> String
```

Retrieves the unique key of the item at `index` from the items source
(WinUI `ItemsSourceView.KeyFromIndex`).

Panics if the source does not implement `IKeyIndexMapping`
(WinUI throws `hresult_not_implemented`), or if `index` is not the index of an item.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/items_source_view.rs#L84)

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

### index_from_key

```rust
fn index_from_key(self: &Self, key: &str) -> i32
```

Retrieves the index of the item that has the unique key `key`, or `-1` when no item
has it (WinUI `ItemsSourceView.IndexFromKey`).

Panics if the source does not implement `IKeyIndexMapping`
(WinUI throws `hresult_not_implemented`).

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

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

### source

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

Gets the source collection.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/items_source_view.rs#L109)

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

### add_collection_changed

```rust
fn add_collection_changed(self: &Self, handler: Rc<ItemsChangedHandler>) -> u64
```

Occurs when the collection has changed to indicate the reason for
the change and which items changed. Returns the token for
`remove_collection_changed`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/items_source_view.rs#L125)

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

### remove_collection_changed

```rust
fn remove_collection_changed(self: &Self, token: u64)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/items_source_view.rs#L130)

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

### get_at

```rust
fn get_at(self: &Self, index: usize) -> Option<BoxedValue>
```

Retrieves the item at the specified index. Panics if out of range.

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

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

### contains

```rust
fn contains(self: &Self, item: &Option<BoxedValue>) -> bool
```

Whether the collection contains the item.

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

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

### index_of

```rust
fn index_of(self: &Self, item: &Option<BoxedValue>) -> i32
```

The index of the item, or `-1`.

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

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

### get_or_create

```rust
fn get_or_create(items: Option<&ItemsSource>) -> Rc<ItemsSourceView>
```

Gets or creates an `ItemsSourceView` for the specified source.

Returns `empty` if `items` is `None`, the view itself if `items`
is a view (`ItemsSourceView isv => isv`), otherwise a new view.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/items_source_view.rs#L182)

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

### get_or_create_of

```rust
fn get_or_create_of<T: PropertyValue>(items: Option<&ItemsSource>) -> ItemsSourceViewOf<T>
```

Gets or creates a typed view for the specified source.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/items_source_view.rs#L193)

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

### iter

```rust
fn iter(self: &Self) -> impl Iterator<Item = Option<BoxedValue>>
```

The items, enumerated by index over the live collection.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/items_source_view.rs#L201)

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

### to_vec

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

A copy of the items.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/items_source_view.rs#L215)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- [`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/)
- `PartialEq`
- [`IItemsList`](/docs/0.5.0/api/ferroui-controls/trait-iitemslist/)
- [`IKeyIndexMapping`](/docs/0.5.0/api/ferroui-controls/trait-ikeyindexmapping/)
- [`ICollectionChangedListener`](/docs/0.5.0/api/ferroui-controls/utils/trait-icollectionchangedlistener/)

## Availability

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