# BehaviorCollection

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-xaml-interactivity/struct-behaviorcollection/

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

```rust
struct BehaviorCollection
```

Represents a collection of [`IBehavior`](/docs/0.5.0/api/ferroui-xaml-interactivity/trait-ibehavior/)s with a shared
`associated_object`.

The collection is a notifying list of objects (`FerroList<FerroObject>`); every item must be
a behavior. It is a reference object: clones refer to the same collection and compare by
identity.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/collections/behavior_collection.rs#L18)

## Members

- [`new`](#function-new)
- [`list`](#function-list)
- [`associated_object`](#function-associated_object)
- [`attach`](#function-attach)
- [`detach`](#function-detach)

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

### new

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

Initializes a new instance of the `BehaviorCollection` class.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/collections/behavior_collection.rs#L114)

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

### list

```rust
fn list(self: &Self) -> &FerroList<Ref<FerroObject>>
```

The list of the collection.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/collections/behavior_collection.rs#L137)

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

### associated_object

```rust
fn associated_object(self: &Self) -> Option<Ref<FerroObject>>
```

Gets the object to which the `BehaviorCollection` is attached.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/collections/behavior_collection.rs#L142)

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

### attach

```rust
fn attach(self: &Self, associated_object: impl Into<Nullable<FerroObject>>)
```

Attaches the collection of behaviors to the specified object.
## Panics
Panics if the `BehaviorCollection` is already attached to a different object.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/collections/behavior_collection.rs#L155)

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

### detach

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

Detaches the collection of behaviors from the
`associated_object`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/collections/behavior_collection.rs#L196)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- [`Receiver`](/docs/0.5.0/api/ferroui-system/task/oneshot/struct-receiver/)
- `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`
- `Deref`
- `Default`
- `Debug`
- [`MarkupTyped`](/docs/0.5.0/api/ferroui-base/metadata/trait-markuptyped/)

## Availability

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