# BehaviorOfT

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

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

```rust
struct BehaviorOfT
```

A base class for behaviors making them code compatible with older frameworks, and allow for
typed associated objects (`Behavior<T>`).

Deviation (DEVIATIONS.md, Behaviors): classes of the class model are not generic. The type
argument `T` of the reference is the runtime type a deriving class passes to
`construct`; attaching the behavior to an object of another type panics as
the reference throws, and `associated_object_as` is the typed
`AssociatedObject` of the reference.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/ferro_object/behavior_of_t.rs#L15)

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`construct`](#function-construct)
- [`associated_type`](#function-associated_type)
- [`associated_object_as`](#function-associated_object_as)

<a id="assoc_const-type"></a>

### TYPE

```rust
const TYPE: &'static $crate::TypeInfo
```

The runtime type of this class.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/ferro_object/behavior_of_t.rs#L20)

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

### to_ref

```rust
fn to_ref(self: &Self) -> $crate::Ref<BehaviorOfT>
```

Returns a strong reference to this object.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/ferro_object/behavior_of_t.rs#L20)

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

### construct

```rust
fn construct(associated_type: &'static TypeInfo) -> Self
```

Creates the class data for behaviors attached to objects of `associated_type` (the `T` of
the reference); see `FerroObject::construct`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/ferro_object/behavior_of_t.rs#L58)

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

### associated_type

```rust
fn associated_type(self: &Self) -> &'static TypeInfo
```

The type of the objects the behavior attaches to (the `T` of the reference).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/ferro_object/behavior_of_t.rs#L63)

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

### associated_object_as

```rust
fn associated_object_as<T: ObjectType>(self: &Self) -> Option<Ref<T>>
```

Gets the object to which this behavior is attached, as `T`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/ferro_object/behavior_of_t.rs#L68)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`BehaviorImplExt`](/docs/0.5.0/api/ferroui-xaml-interactivity/trait-behaviorimplext/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- [`Receiver`](/docs/0.5.0/api/ferroui-system/task/oneshot/struct-receiver/)
- `Any`
- [`FerroObjectImplExt`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimplext/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`
- `Deref`
- [`Upcast<T>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`Upcast<BehaviorOfT>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`StaticType`](/docs/0.5.0/api/ferroui-base/trait-statictype/)
- [`ObjectType`](/docs/0.5.0/api/ferroui-base/trait-objecttype/)
- [`Subclassable<T>`](/docs/0.5.0/api/ferroui-base/trait-subclassable/)
- [`FerroObjectImpl`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimpl/)
- [`BehaviorImpl`](/docs/0.5.0/api/ferroui-xaml-interactivity/trait-behaviorimpl/)

## Availability

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