Skip to content

ViewModelViewHost class

Attributes: [DebuggerDisplay("{ViewContractObservable}, {DefaultContent}")] [WinRTRuntimeClassName("Microsoft.UI.Xaml.IUIElementOverrides")] [WinRTExposedType(typeof(ViewModelViewHostWinRTTypeDetails))]

Defined in

Namespace: ReactiveUI.Reactive Assembly: ReactiveUI.WinUI.Reactive.dll Full name: ReactiveUI.Reactive.ViewModelViewHost Modifiers: public

Summary

View source

        This content control will automatically load the View associated with
        the ViewModel property and display it. This control is very useful
        inside a DataTemplate to display the View associated with a ViewModel.

Applies to

net11.0-windows10.0.19041, net11.0-windows10.0.19041, net11.0-windows7.0, net11.0-ios27.2, net11.0-maccatalyst27.2, net11.0-tvos27.2, net11.0-macos27.2, net10.0-windows10.0.19041, net10.0-windows10.0.19041, net10.0-macos26.0, net10.0-tvos26.0, net10.0-maccatalyst26.0, net10.0-windows7.0, net10.0-ios26.0, net47, net471, net472, net48, net481

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

Inherits from: TransitioningContentControl

Implements: IViewFor, IActivatableView, IEnableLogger

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
ViewContractObservableGets or sets the view contract observable.
DefaultContentGets or sets the content displayed by default when no content is set.
ViewModelGets or sets the ViewModel to display.
ViewContractGets or sets the view contract.
ContractFallbackByPassGets or sets a value indicating whether should bypass the default contract fallback behavior.
ViewLocatorGets or sets the view locator.

Fields

NameSummary
static DefaultContentPropertyThe default content dependency property.
static ViewModelPropertyThe view model dependency property.
static ViewContractObservablePropertyThe view contract observable dependency property.
static ContractFallbackByPassPropertyThe ContractFallbackByPass dependency property.

Methods

NameSummary
ResolveViewForViewModelResolve view for view model with respect to contract.

Derived types

Inherited members