Method ShowDialogAsync
ShowDialogAsync<TViewModel>(TViewModel, out IDialogNavigator)
Shows a dialog with the specified view model and returns a task that completes when the dialog closes.
Declaration
Task ShowDialogAsync<TViewModel>(TViewModel viewModel, out IDialogNavigator dialogNavigator) where TViewModel : class
Parameters
Type | Name | Description |
---|---|---|
TViewModel | viewModel | The view model for the dialog. |
IDialogNavigator | dialogNavigator | Contains the dialog navigator for the dialog when the method returns. |
Returns
Type | Description |
---|---|
Task |
Type Parameters
Name | Description |
---|---|
TViewModel |
Remarks
This method is typically used to:
- Show the dialog for a view model that receives an IDialogNavigator instance through a mechanism other than a constructor parameter
(like a property setter or method call, for example). The output
dialogNavigator
should be provided to the view model prior to awaiting the returned task. - Show a dialog where the caller of this method controls closing the dialog instead of the dialog itself, using the output
dialogNavigator
. The caller should call Close() before awaiting the returned task (or pass it to something else that will call it when the dialog should close). - Show a dialog that was previously shown again. The output
dialogNavigator
can be ignored in this case, as it will be the same instance that was provided when the dialog was first shown.
ShowDialogAsync<TViewModel>(Func<IDialogNavigator, TViewModel>)
Shows a dialog with the view model created by the specified function and returns a task that contains the view model when the dialog closes.
Declaration
Task<TViewModel> ShowDialogAsync<TViewModel>(Func<IDialogNavigator, TViewModel> createModelFunc) where TViewModel : class
Parameters
Type | Name | Description |
---|---|---|
Func<IDialogNavigator, TViewModel> | createModelFunc | A function that creates the view model for the dialog. The dialog navigator provided by the function can be used to show nested dialogs or close the dialog. |
Returns
Type | Description |
---|---|
Task<TViewModel> |
Type Parameters
Name | Description |
---|---|
TViewModel |
Remarks
This method should only be used when showing a dialog for the first time when its view model has an IDialogNavigator constructor parameter
that needs to be provided (which should be done in createModelFunc
). For all other cases, use a different overload.
ShowDialogAsync<TViewModel>(out TViewModel, Func<IDialogNavigator, TViewModel>)
Shows a dialog with the view model created by the specified function and returns a task that completes when the dialog closes.
Declaration
Task ShowDialogAsync<TViewModel>(out TViewModel viewModel, Func<IDialogNavigator, TViewModel> createModelFunc) where TViewModel : class
Parameters
Type | Name | Description |
---|---|---|
TViewModel | viewModel | Contains the view model for the dialog when the method returns. |
Func<IDialogNavigator, TViewModel> | createModelFunc | A function that creates the view model for the dialog. The dialog navigator provided by the function can be used to show nested dialogs or close the dialog. |
Returns
Type | Description |
---|---|
Task |
Type Parameters
Name | Description |
---|---|
TViewModel |
Remarks
This method should only be used when showing a dialog for the first time when its view model has an IDialogNavigator constructor parameter
that needs to be provided (which should be done in createModelFunc
) and the view model is needed before the task returns. For all
other cases, use a different overload.