# DelayedBinding

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-markup/markup/data/struct-delayedbinding/

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

```rust
struct DelayedBinding
```

Provides delayed bindings for elements.

The markup engine applies its bindings in a delayed manner: bindings are
only applied when an element has finished initializing. Applying bindings
as soon as elements are created would mean that long-form bindings
(binding objects whose properties are set one by one after creation)
don't work, as the binding would be applied to the property before the
properties of the binding object are set.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup/markup/data/delayed_binding.rs#L18)

## Members

- [`add`](#function-add)
- [`add_value`](#function-add_value)
- [`prepare_values`](#function-prepare_values)
- [`apply_bindings`](#function-apply_bindings)

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

### add

```rust
fn add(target: &StyledElement, property: &'static FerroProperty, binding: Rc<dyn BindingBase>)
```

Adds a delayed binding to an element: the binding is applied to
`property` when the element has finished initializing, or immediately
if it already has.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup/markup/data/delayed_binding.rs#L63)

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

### add_value

```rust
fn add_value(target: &StyledElement, property: Rc<dyn IPropertyInfo>, value: impl Fn(&StyledElement) -> Option<BoxedValue> + 'static) -> Result<(), BindingError>
```

Adds a delayed value to an element: `value` is evaluated and written
to `property` when the element has finished initializing, or
immediately if it already has.

When the value is written immediately, an error from the property
setter is returned (the equivalent of the setter throwing to the
caller); when it is written later, the error is logged.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup/markup/data/delayed_binding.rs#L78)

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

### prepare_values

```rust
fn prepare_values(control: &StyledElement) -> Result<(), BindingError>
```

Resolves deferred markup values on a detached reload candidate without
activating its data bindings or raising Initialized. Unlike ordinary
initialization, setter errors abort preparation instead of being logged.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup/markup/data/delayed_binding.rs#L133)

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

### apply_bindings

```rust
fn apply_bindings(control: &StyledElement)
```

Applies any delayed bindings to an element.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup/markup/data/delayed_binding.rs#L165)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`

## Availability

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