# StyledElementBehavior

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

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

```rust
struct StyledElementBehavior
```

A base class for behaviors, implementing the basic plumbing of [`IBehavior`](/docs/0.5.0/api/ferroui-xaml-interactivity/trait-ibehavior/).

The behavior is a styled element: while its host is in the logical tree, the behavior is a
logical child of the host (one way: it is not in the logical children of the host), so it is
styled, resolves resources, follows the data context of its host and binds with `$parent`
and `TemplateBinding`.

The class is abstract: deriving classes override the members of [`StyledElementBehaviorImpl`](/docs/0.5.0/api/ferroui-xaml-interactivity/trait-styledelementbehaviorimpl/).
See `Behavior` for the names of the hooks of the logical tree.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/styled_element/styled_element_behavior.rs#L25)

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`on_attached`](#function-on_attached)
- [`on_detaching`](#function-on_detaching)
- [`on_attached_to_visual_tree`](#function-on_attached_to_visual_tree)
- [`on_detached_from_visual_tree`](#function-on_detached_from_visual_tree)
- [`on_attached_to_logical_tree_event`](#function-on_attached_to_logical_tree_event)
- [`on_detached_from_logical_tree_event`](#function-on_detached_from_logical_tree_event)
- [`on_loaded`](#function-on_loaded)
- [`on_unloaded`](#function-on_unloaded)
- [`on_initialized_event`](#function-on_initialized_event)
- [`on_data_context_changed_event`](#function-on_data_context_changed_event)
- [`on_resources_changed_event`](#function-on_resources_changed_event)
- [`on_actual_theme_variant_changed_event`](#function-on_actual_theme_variant_changed_event)
- [`is_enabled_property`](#function-is_enabled_property)
- [`construct`](#function-construct)
- [`associated_object`](#function-associated_object)
- [`associated_styled_element`](#function-associated_styled_element)
- [`is_enabled`](#function-is_enabled)
- [`set_is_enabled`](#function-set_is_enabled)
- [`attach`](#function-attach)
- [`detach`](#function-detach)

<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/styled_element/styled_element_behavior.rs#L37)

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

### to_ref

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

Returns a strong reference to this object.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/styled_element/styled_element_behavior.rs#L37)

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

### on_attached

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

Called after the behavior is attached to the associated object.

Override this to hook up functionality to the associated object.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/styled_element/styled_element_behavior.rs#L37)

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

### on_detaching

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

Called when the behavior is being detached from its associated object.

Override this to unhook functionality from the associated object.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/styled_element/styled_element_behavior.rs#L37)

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

### on_attached_to_visual_tree

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

Called after the associated object is attached to the visual tree.

Invoked only when the associated object is a visual.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/styled_element/styled_element_behavior.rs#L37)

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

### on_detached_from_visual_tree

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

Called when the associated object is being detached from the visual tree.

Invoked only when the associated object is a visual.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/styled_element/styled_element_behavior.rs#L37)

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

### on_attached_to_logical_tree_event

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

Called after the associated object is attached to the logical tree
(`OnAttachedToLogicalTree`).

Invoked only when the associated object is a styled element.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/styled_element/styled_element_behavior.rs#L37)

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

### on_detached_from_logical_tree_event

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

Called when the associated object is being detached from the logical tree
(`OnDetachedFromLogicalTree`).

Invoked only when the associated object is a styled element.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/styled_element/styled_element_behavior.rs#L37)

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

### on_loaded

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

Called after the associated object is loaded.

Invoked only when the associated object is a control.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/styled_element/styled_element_behavior.rs#L37)

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

### on_unloaded

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

Called when the associated object is unloaded.

Invoked only when the associated object is a control.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/styled_element/styled_element_behavior.rs#L37)

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

### on_initialized_event

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

Called when the associated object is initialized.

Invoked only when the associated object is a styled element.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/styled_element/styled_element_behavior.rs#L37)

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

### on_data_context_changed_event

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

Called when the data context of the associated object changed.

Invoked only when the associated object is a styled element.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/styled_element/styled_element_behavior.rs#L37)

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

### on_resources_changed_event

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

Called when the resources of the associated object changed.

Invoked only when the associated object is a styled element.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/styled_element/styled_element_behavior.rs#L37)

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

### on_actual_theme_variant_changed_event

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

Called when the actual theme variant of the associated object changed.

Invoked only when the associated object is a styled element.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/styled_element/styled_element_behavior.rs#L37)

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

### is_enabled_property

```rust
fn is_enabled_property() -> &'static StyledProperty<bool>
```

Identifies the `IsEnabled` property.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/styled_element/styled_element_behavior.rs#L175)

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

### construct

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

Creates the class data; see `FerroObject::construct`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/styled_element/styled_element_behavior.rs#L204)

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

### associated_object

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

Gets the object to which the behavior is attached.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/styled_element/styled_element_behavior.rs#L217)

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

### associated_styled_element

```rust
fn associated_styled_element(self: &Self) -> Option<Ref<StyledElement>>
```

Gets the styled element to which this behavior is attached.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/styled_element/styled_element_behavior.rs#L222)

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

### is_enabled

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

Gets or sets a value indicating whether this instance is enabled.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/styled_element/styled_element_behavior.rs#L227)

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

### set_is_enabled

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/styled_element/styled_element_behavior.rs#L231)

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

### attach

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

Attaches the behavior to the specified object.
## Panics
Panics if the behavior is attached to another object.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/styled_element/styled_element_behavior.rs#L239)

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

### detach

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

Detaches the behaviors from the `associated_object`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/styled_element/styled_element_behavior.rs#L268)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`StyledElementBehaviorImplExt`](/docs/0.5.0/api/ferroui-xaml-interactivity/trait-styledelementbehaviorimplext/)
- `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/)
- [`StyledElementImplExt`](/docs/0.5.0/api/ferroui-base/trait-styledelementimplext/)
- [`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<StyledElementBehavior>`](/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/)
- [`StyledElementImpl`](/docs/0.5.0/api/ferroui-base/trait-styledelementimpl/)
- [`StyledElementBehaviorImpl`](/docs/0.5.0/api/ferroui-xaml-interactivity/trait-styledelementbehaviorimpl/)
- [`IBehavior`](/docs/0.5.0/api/ferroui-xaml-interactivity/trait-ibehavior/)
- [`IBehaviorEventsHandler`](/docs/0.5.0/api/ferroui-xaml-interactivity/trait-ibehavioreventshandler/)

## Availability

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