# ViewModelViewHost

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-reactiveui-controls/struct-viewmodelviewhost/

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

```rust
struct ViewModelViewHost
```

Loads and displays the view associated with the `ViewModel` property (`ViewModelViewHost`).

Assigning a view model resolves its view through the view locator (`view_locator` or the
current one) under the `view_contract`; the view gets the view model through its `ViewModel`
and `DataContext`. Without a view model, or without a view for it, the host shows its
`default_content`.





[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/view_model_view_host.rs#L37)

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`view_model_property`](#function-view_model_property)
- [`view_contract_property`](#function-view_contract_property)
- [`default_content_property`](#function-default_content_property)
- [`construct`](#function-construct)
- [`new`](#function-new)
- [`view_model`](#function-view_model)
- [`set_view_model`](#function-set_view_model)
- [`view_contract`](#function-view_contract)
- [`set_view_contract`](#function-set_view_contract)
- [`default_content`](#function-default_content)
- [`set_default_content`](#function-set_default_content)
- [`view_locator`](#function-view_locator)
- [`set_view_locator`](#function-set_view_locator)
- [`view_for`](#function-view_for)
- [`navigate_to_view_model`](#function-navigate_to_view_model)
- [`dispose_navigation_disposables`](#function-dispose_navigation_disposables)

<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/FerroUI.ReactiveUI.Controls/view_model_view_host.rs#L46)

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

### to_ref

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

Returns a strong reference to this object.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/view_model_view_host.rs#L46)

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

### view_model_property

```rust
fn view_model_property() -> &'static StyledProperty<Option<BoxedValue>>
```

Identifies the `ViewModel` property (`ViewModelProperty`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/view_model_view_host.rs#L85)

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

### view_contract_property

```rust
fn view_contract_property() -> &'static StyledProperty<Option<String>>
```

Identifies the `ViewContract` property (`ViewContractProperty`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/view_model_view_host.rs#L85)

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

### default_content_property

```rust
fn default_content_property() -> &'static StyledProperty<Option<BoxedValue>>
```

Identifies the `DefaultContent` property (`DefaultContentProperty`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/view_model_view_host.rs#L85)

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

### construct

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

Field initialisation.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/view_model_view_host.rs#L106)

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

### new

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

Creates the host.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/view_model_view_host.rs#L115)

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

### view_model

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

The view model whose view is shown (`ViewModel`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/view_model_view_host.rs#L120)

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

### set_view_model

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

Sets the view model whose view is shown.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/view_model_view_host.rs#L125)

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

### view_contract

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

The contract of the view to resolve (`ViewContract`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/view_model_view_host.rs#L130)

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

### set_view_contract

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

Sets the contract of the view to resolve.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/view_model_view_host.rs#L135)

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

### default_content

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

The content shown when there is no view model or no view for it (`DefaultContent`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/view_model_view_host.rs#L140)

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

### set_default_content

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

Sets the content shown when there is no view model or no view for it.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/view_model_view_host.rs#L145)

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

### view_locator

```rust
fn view_locator(self: &Self) -> Option<Rc<dyn IViewLocator>>
```

The view locator used to resolve views (`ViewLocator`); `None` uses the current one.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/view_model_view_host.rs#L150)

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

### set_view_locator

```rust
fn set_view_locator(self: &Self, value: Option<Rc<dyn IViewLocator>>)
```

Sets the view locator used to resolve views.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/view_model_view_host.rs#L155)

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

### view_for

```rust
fn view_for(this: &Ref<Self>) -> Rc<dyn IViewFor>
```

The host as a view of ReactiveUI (`(IViewFor)host`), which keeps it alive.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/view_model_view_host.rs#L160)

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

### navigate_to_view_model

```rust
fn navigate_to_view_model(self: &Self, view_model: Option<Rc<dyn Any>>, contract: Option<&str>)
```

Navigates to the view associated with `view_model` and `contract` (`NavigateToViewModel`):
a missing view model or view displays the default content; a resolved view receives the
view model through its `ViewModel` and `DataContext`.

Deviation (DEVIATIONS.md, ReactiveUI controls): internal upstream, public here so that the
tests, in another module, reach it.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/view_model_view_host.rs#L170)

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

### dispose_navigation_disposables

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

Disposes the active navigation subscriptions when they exist
(`DisposeNavigationDisposables`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/view_model_view_host.rs#L185)

## 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`
- [`TemplatedControlImplExt`](/docs/0.5.0/api/ferroui-controls/primitives/trait-templatedcontrolimplext/)
- [`ContentControlImplExt`](/docs/0.5.0/api/ferroui-controls/trait-contentcontrolimplext/)
- [`ControlImplExt`](/docs/0.5.0/api/ferroui-controls/trait-controlimplext/)
- `Deref`
- [`Upcast<T>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`Upcast<ViewModelViewHost>`](/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/)
- [`FerroObjectImpl`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimpl/)
- [`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/)
- [`TemplatedControlImpl`](/docs/0.5.0/api/ferroui-controls/primitives/trait-templatedcontrolimpl/)
- [`ContentControlImpl`](/docs/0.5.0/api/ferroui-controls/trait-contentcontrolimpl/)
- [`IEnableLogger`](/docs/0.5.0/api/ferroui-splat/logging/trait-ienablelogger/)
- [`StyledElementImpl`](/docs/0.5.0/api/ferroui-base/trait-styledelementimpl/)
- [`VisualImpl`](/docs/0.5.0/api/ferroui-base/trait-visualimpl/)
- [`IReactiveViewClass`](/docs/0.5.0/api/ferroui-reactiveui-controls/trait-ireactiveviewclass/)

## Availability

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