# DeferredElement

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-markup-xaml/markup_extensions/struct-deferredelement/

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

```rust
struct DeferredElement
```

The placeholder of an element with `x:Load` (or `x:DeferLoadStrategy="Lazy"`).

The compiler replaces the element by a placeholder that holds it as deferred content
(`content`, built as a template is) with its name
(`element_name`) and the value of `x:Load` (`load`,
a literal or an `{x:Bind}`). The placeholder takes no room and is not shown. When `Load`
becomes `true` (or `find_name` asks for the element), the element is built
and takes the place of the placeholder in its parent (a panel, a decorator or a content
control); when `Load` becomes `false` the placeholder takes its place again and the element is
released, so that loading it again builds a new one (WinUI's `UnloadObject`).

The element is built with the root of its document and a name scope of its own, a child of
the one of the document: its `x:Bind` bindings read the root of the document (or the item of
the template instance it is in, or its templated parent), and its named elements are found in
that scope, from it and through `find_name`. Inside a control template the
element is given the templated parent of the template instance, so that a bound `x:Load` in a
control template works as in a page (WinUI's fix of bound `x:Load` in control templates).

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/markup_extensions/x_bind/deferred_element.rs#L45)

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`load_property`](#function-load_property)
- [`placeholder_property`](#function-placeholder_property)
- [`construct`](#function-construct)
- [`new`](#function-new)
- [`element_name`](#function-element_name)
- [`set_element_name`](#function-set_element_name)
- [`content`](#function-content)
- [`set_content`](#function-set_content)
- [`is_load_requested`](#function-is_load_requested)
- [`set_load`](#function-set_load)
- [`loaded_element`](#function-loaded_element)
- [`error`](#function-error)
- [`load`](#function-load)
- [`unload`](#function-unload)
- [`find_name`](#function-find_name)

<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/Markup/FerroUI.Markup.Xaml/markup_extensions/x_bind/deferred_element.rs#L56)

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

### to_ref

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

Returns a strong reference to this object.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/markup_extensions/x_bind/deferred_element.rs#L56)

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

### load_property

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

`x:Load`: whether the element is loaded.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/markup_extensions/x_bind/deferred_element.rs#L75)

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

### placeholder_property

```rust
fn placeholder_property() -> &'static AttachedProperty<Option<Ref<DeferredElement>>>
```

The placeholder a loaded element replaces, which the element holds while it is loaded.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/markup_extensions/x_bind/deferred_element.rs#L75)

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

### construct

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

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/markup_extensions/x_bind/deferred_element.rs#L104)

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

### new

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/markup_extensions/x_bind/deferred_element.rs#L114)

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

### element_name

```rust
fn element_name(self: &Self) -> Option<String>
```

The `x:Name` of the deferred element.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/markup_extensions/x_bind/deferred_element.rs#L122)

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

### set_element_name

```rust
fn set_element_name(self: &Self, value: Option<String>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/markup_extensions/x_bind/deferred_element.rs#L126)

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

### content

```rust
fn content(self: &Self) -> Option<BoxedValue>
```

The deferred element: deferred content, built as the content of a template is.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/markup_extensions/x_bind/deferred_element.rs#L131)

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

### set_content

```rust
fn set_content(self: &Self, value: Option<BoxedValue>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/markup_extensions/x_bind/deferred_element.rs#L135)

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

### is_load_requested

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

The value of `x:Load`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/markup_extensions/x_bind/deferred_element.rs#L140)

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

### set_load

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/markup_extensions/x_bind/deferred_element.rs#L144)

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

### loaded_element

```rust
fn loaded_element(self: &Self) -> Option<Ref<Control>>
```

The element, while it is loaded.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/markup_extensions/x_bind/deferred_element.rs#L149)

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

### error

```rust
fn error(self: &Self) -> Option<String>
```

Why the last change of `Load` could not be applied (a placeholder whose parent does not
hold it as a child, content that is not a control), if it could not.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/markup_extensions/x_bind/deferred_element.rs#L155)

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

### load

```rust
fn load(self: &Self) -> Result<Option<Ref<Control>>, XamlLoadError>
```

Builds the element and puts it in the place of the placeholder (`FindName` of WinUI on a
deferred element); the element when it is already loaded. `None` while the placeholder
has no parent, or when the content builds nothing.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/markup_extensions/x_bind/deferred_element.rs#L173)

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

### unload

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

Puts the placeholder back in the place of the loaded element and releases the element
(`UnloadObject`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/markup_extensions/x_bind/deferred_element.rs#L208)

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

### find_name

```rust
fn find_name(scope: &StyledElement, name: &str) -> Result<Option<Ref<FerroObject>>, XamlLoadError>
```

WinUI's `FindName` with the realization of `x:Load`: the element named `name` in the name
scope of `scope`, else a deferred element of that name among the logical descendants of
`scope`, loaded if it is not, else a named element of a loaded deferred element.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/markup_extensions/x_bind/deferred_element.rs#L227)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `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`
- [`InputElementImplExt`](/docs/0.5.0/api/ferroui-base/input/trait-inputelementimplext/)
- [`InteractiveImplExt`](/docs/0.5.0/api/ferroui-base/interactivity/trait-interactiveimplext/)
- [`LayoutableImplExt`](/docs/0.5.0/api/ferroui-base/layout/trait-layoutableimplext/)
- [`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/)
- [`VisualImplExt`](/docs/0.5.0/api/ferroui-base/trait-visualimplext/)
- `ErasedDestructor`
- `IntoEither`
- [`ControlImplExt`](/docs/0.5.0/api/ferroui-controls/trait-controlimplext/)
- `Deref`
- [`Upcast<T>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`Upcast<DeferredElement>`](/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/)
- [`DefaultConstructible`](/docs/0.5.0/api/ferroui-base/trait-defaultconstructible/)
- [`StyledElementImpl`](/docs/0.5.0/api/ferroui-base/trait-styledelementimpl/)
- [`VisualImpl`](/docs/0.5.0/api/ferroui-base/trait-visualimpl/)
- [`LayoutableImpl`](/docs/0.5.0/api/ferroui-base/layout/trait-layoutableimpl/)
- [`InteractiveImpl`](/docs/0.5.0/api/ferroui-base/interactivity/trait-interactiveimpl/)
- [`InputElementImpl`](/docs/0.5.0/api/ferroui-base/input/trait-inputelementimpl/)
- [`ControlImpl`](/docs/0.5.0/api/ferroui-controls/trait-controlimpl/)
- [`FerroObjectImpl`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimpl/)

## Availability

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