# TemplateContent

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

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

```rust
struct TemplateContent
```

Builds the content of templates.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/templates/template_content.rs#L12)

## Members

- [`load`](#function-load)
- [`load_as`](#function-load_as)
- [`try_load_as`](#function-try_load_as)

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

### load

```rust
fn load(template_content: Option<&BoxedValue>) -> Option<TemplateResult<Ref<Control>>>
```

Builds template content whose result is a control.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/templates/template_content.rs#L16)

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

### load_as

```rust
fn load_as<T: Clone + 'static>(template_content: Option<&BoxedValue>) -> Option<TemplateResult<T>>
```

Builds template content (the value of a `Content` property marked as
template content) whose result is a `T`: the result and the name
scope its named elements were registered in.

Returns `None` for no content, and for content that built nothing.

The content is the deferred content object the runtime helpers
create (`DeferredContent`). The delegate form of the managed
original has no counterpart: a function is not an untyped value.

Inside an error scope of a load
(`with_xaml_errors`), a
failure is the error of the scope and the template builds nothing.
## Panics
Outside an error scope, panics if the content is anything else, or if
what it built is not a `T`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/templates/template_content.rs#L37)

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

### try_load_as

```rust
fn try_load_as<T: Clone + 'static>(template_content: Option<&BoxedValue>) -> Result<Option<TemplateResult<T>>, XamlLoadError>
```

`load_as` without panics: unexpected content and a
result of another type are errors. This is what untyped (metadata)
callers use.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/templates/template_content.rs#L44)

## 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`
- [`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/).
