Method CreateDialogViewModel
CreateDialogViewModel<TViewModel>(params object?[])
Creates a dialog view model with constructor injection, the same way the navigator creates routed view models. Explicit arguments are matched to
constructor parameters by type (positionally among parameters of the same type); remaining parameters are resolved from services provided by the
view models of the dialogs this presenter is nested in and of the active route (nearest first), then from RootServices, then from
parameter default values. A view model provides a service the same way a parent routed view model does for its children: a child service registered
with SetChildService, else a service from its IServiceProvider implementation, else the view model itself if it implements or
derives from the parameter type. The view model's Navigator is available inside its constructor, and the dialog only receives the view model
as its data context once the constructor has finished.
Declaration
public TViewModel CreateDialogViewModel<TViewModel>(params object?[] explicitArgs) where TViewModel : class, IDialogViewModel
Parameters
| Type | Name | Description |
|---|---|---|
| object[] | explicitArgs | Values for constructor parameters that are not services (e.g. the item being edited). Must not contain nulls. |
Returns
| Type | Description |
|---|---|
| TViewModel |
Type Parameters
| Name | Description |
|---|---|
| TViewModel | The dialog view model type, which must have a single public constructor. |
Implements
Remarks
A dialog view model created by a presenter can only be shown by that presenter, since the services it received were resolved in that presenter's scope. If any service came from a view model that is no longer active when the dialog is shown, showing it throws. Create dialog view models immediately before showing them.