> For the complete documentation index, see [llms.txt](https://funcui.avaloniaui.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://funcui.avaloniaui.net/view-basics/lifetime.md).

# Lifetime

Every FuncUI view is backed by an Avalonia Control. Even when attributes of a view change, the backing control does not change. Instead, changes are mirrored to the backing Control. This is often called "patching".

<img src="/files/UQ1PA4iLAr3SZQIJInPx" alt="" class="gitbook-drawing">

Views don't hold a reference to their backing Avalonia control. The backing control is determined by the view structure.

<img src="/files/LfIh43CBPFvcotHTAdqK" alt="" class="gitbook-drawing">

This means if the structure changes the backing control also does change. FuncUI will ensure the new backing control is patched / has all attributes set as specified in the view.

If the view type in the structure does not match the view type in the backing structure a new backing control is created.

<img src="/files/vORLtwKKFOfRsuYXb1eB" alt="" class="gitbook-drawing">

{% hint style="info" %}
Only backing views of the same type can be reused when the view structure changes.
{% endhint %}

## Keyed Views

Sometimes you need more control over the reuse of backing controls. This can be achieved by specifying a view key.\
\
If the view key changes a new backing view is created, no patching is attempted.

```fsharp
[ 
    // View attributes
]
|> Button.create
|> View.withKey "button-1"
```

```fsharp
View.createWithKey "button-1" Button.create [
    // View attributes
]
```
