# DataTemplate

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

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

```rust
struct DataTemplate
```

A template that builds the control that presents a piece of data, as
markup declares it.

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

## Members

- [`new`](#function-new)
- [`data_type`](#function-data_type)
- [`set_data_type`](#function-set_data_type)
- [`content`](#function-content)
- [`set_content`](#function-set_content)
- [`match_`](#function-match_)
- [`build`](#function-build)
- [`build_with_existing`](#function-build_with_existing)
- [`from_data_template`](#function-from_data_template)
- [`as_data_template`](#function-as_data_template)

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

### new

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



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

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

### data_type

```rust
fn data_type(self: &Self) -> Option<ValueType>
```

The type of data the template is for: the handle type of a class
(`Ref<T>`), the type of a model object or of a value. `None` matches
all data.

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

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

### set_data_type

```rust
fn set_data_type(self: &Self, value: Option<ValueType>)
```



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

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

### content

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

The template content: deferred content built for each piece of data.

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

<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/templates/data_template.rs#L81)

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

### match_

```rust
fn match_(self: &Self, data: Option<&BoxedValue>) -> bool
```

Whether the template is for `data`.

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

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

### build

```rust
fn build(self: &Self, data: Option<&BoxedValue>) -> Option<Ref<Control>>
```

Builds the control for `data`.

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

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

### build_with_existing

```rust
fn build_with_existing(self: &Self, _data: Option<&BoxedValue>, existing: Option<Ref<Control>>) -> Option<Ref<Control>>
```

Builds the control for `data`, or reuses `existing`.

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

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

### from_data_template

```rust
fn from_data_template(template: &Rc<dyn IDataTemplate>) -> Option<Rc<DataTemplate>>
```

The template behind a data template handle, if it is one of this
class (the cast of the contract back to the class).

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

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

### as_data_template

```rust
fn as_data_template(self: &Self) -> Rc<dyn IDataTemplate>
```

The template as the data template contract.

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

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`
- [`ITemplateWithParam<Option<Rc<dyn AnyValue>>, Option<Ref<Control>>>`](/docs/0.5.0/api/ferroui-controls/templates/trait-itemplatewithparam/)
- [`IDataTemplate`](/docs/0.5.0/api/ferroui-controls/templates/trait-idatatemplate/)
- [`IRecyclingDataTemplate`](/docs/0.5.0/api/ferroui-controls/templates/trait-irecyclingdatatemplate/)
- [`ITypedDataTemplate`](/docs/0.5.0/api/ferroui-controls/templates/trait-itypeddatatemplate/)
- `PartialEq`
- [`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/).
