Skip to content

ViewModelViewHost class

Attributes: [DebuggerDisplay("{ViewModel}, {DefaultContent}")]

Defined in

Namespace: ReactiveUI.Maui Assembly: ReactiveUI.Maui.dll Full name: ReactiveUI.Maui.ViewModelViewHost Modifiers: public

Summary

View source

This content view will automatically load and host the view for the given view model. The view model whose view is to be displayed should be assigned to the ViewModel property. Optionally, the chosen view can be customized by specifying a contract via ViewContractObservable or ViewContract.

Applies to

net10.0, net10.0-ios26.0, net10.0-maccatalyst26.0, net10.0-android36.0, net10.0-tvos26.0, net10.0-macos26.0, net10.0-windows10.0.19041

Class hierarchy
classDiagram
class ViewModelViewHost
class ContentView
ContentView <|-- ViewModelViewHost
class IViewFor {
    <>
}
IViewFor <|.. ViewModelViewHost
class IActivatableView {
    <>
}
IActivatableView <|.. ViewModelViewHost

Inherits from: ContentView

Implements: IViewFor, IActivatableView

Remarks

The host asks the view locator for the view by the view model's run-time type, without building any type at run time, so it is safe to trim and to compile ahead of time. The default locator checks the view lookup the source generator writes, then the views the app added with Map. A view registered only with the service locator needs ViewModelViewHostUnsafe, which also asks the service locator for IViewFor closed over the view model's run-time type.

Constructors

NameSummary
.ctorInitializes a new instance of the [ViewModelViewHost](# class.

Properties

NameSummary
ViewModelGets or sets the view model whose associated view is to be displayed.
DefaultContentGets or sets the content to display when [ViewModel](# is null.
ViewContractObservableGets or sets the observable which signals when the contract to use when resolving the view for the given view model has changed.
ViewContractGets or sets the fixed contract to use when resolving the view for the given view model.
ContractFallbackByPassGets or sets a value indicating whether should bypass the default contract fallback behavior.
ViewLocatorGets or sets the override for the view locator to use when resolving the view. If unspecified, the locator registered in the service locator is used.

Fields

NameSummary
static ViewModelPropertyIdentifies the [ViewModel](# property.
static DefaultContentPropertyIdentifies the [DefaultContent](# property.
static ViewContractObservablePropertyIdentifies the [ViewContractObservable](# property.
static ContractFallbackByPassPropertyThe ContractFallbackByPass dependency property.

Methods

NameSummary
ResolveViewForViewModelResolves a view for the view model using the specified contract.

Derived types

Inherited members