# CommandBarElementCollection

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

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

```rust
struct CommandBarElementCollection
```

The read-only, notifying collection of command bar elements that a
[`CommandBar`](/docs/0.5.0/api/ferroui-controls/command_bar/struct-commandbar/) exposes as `VisiblePrimaryCommands` and `OverflowItems`
(the read-only observable collection of the reference).

The collection is a reference object: the value is a shared handle,
clones refer to the same collection and handles compare by identity.
Only the command bar that owns it changes it. As an items source its
elements that are controls are items boxed as controls, so that an
items control presents them as their own containers.

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

## Members

- [`count`](#function-count)
- [`is_empty`](#function-is_empty)
- [`get`](#function-get)
- [`snapshot`](#function-snapshot)
- [`to_vec`](#function-to_vec)
- [`contains`](#function-contains)
- [`index_of`](#function-index_of)
- [`add_collection_changed`](#function-add_collection_changed)
- [`remove_collection_changed`](#function-remove_collection_changed)
- [`as_items_source`](#function-as_items_source)

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

### count

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

The number of elements.

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

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

### is_empty

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

Whether the collection has no elements.

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

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

### get

```rust
fn get(self: &Self, index: usize) -> Rc<dyn ICommandBarElement>
```

The element at `index`. Panics if out of range.

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

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

### snapshot

```rust
fn snapshot(self: &Self) -> Rc<Vec<Rc<dyn ICommandBarElement>>>
```

The elements as they are now. The snapshot shares storage with the
collection until the collection changes.

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

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

### to_vec

```rust
fn to_vec(self: &Self) -> Vec<Rc<dyn ICommandBarElement>>
```

A copy of the elements.

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

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

### contains

```rust
fn contains(self: &Self, element: &Rc<dyn ICommandBarElement>) -> bool
```

Whether the collection contains `element`.

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

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

### index_of

```rust
fn index_of(self: &Self, element: &Rc<dyn ICommandBarElement>) -> Option<usize>
```

The index of `element`, if the collection contains it.

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

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

### add_collection_changed

```rust
fn add_collection_changed(self: &Self, handler: Rc<ferroui_base::collections::CollectionChangedHandler<std::rc::Rc<dyn ICommandBarElement>>>) -> u64
```

Subscribes to the changes of the collection. Returns the token for
`remove_collection_changed`.

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

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

### remove_collection_changed

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

Unsubscribes a handler.

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

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

### as_items_source

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

The collection as the source of the items of an items control.

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

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- [`PropertyValue`](/docs/0.5.0/api/ferroui-base/trait-propertyvalue/)
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`
- `Clone`
- `PartialEq`
- `Debug`
- `From<CommandBarElementCollection>`

## Availability

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