INavigator

Manages application navigation, modal presentations, and native dialogs from a ViewModel.
public interface INavigator

Methods

AlertAsync

Displays an alert dialog with a single button to dismiss it.

Task AlertAsync(
  string title,
  string message,
  string dismiss = "OK")
ParameterSummary
string titleThe title text of the alert.
string messageThe message body.
(optional) string dismissThe text for the dismiss button.

Returns

  • Task: A task representing the async operation.

ConfirmAsync

Displays a confirmation dialog with accept and cancel actions.

Task<bool> ConfirmAsync(
  string title,
  string message,
  string accept = "OK",
  string cancel = "Cancel",
  bool destructive = false)
ParameterSummary
string titleThe title text of the confirmation box.
string messageThe message body.
(optional) string acceptThe text for the confirming button.
(optional) string cancelThe text for the canceling button.
(optional) bool destructiveWhether the confirming button is styled red, for actions that discard something.

Returns

  • Task<bool>: A task containing true if accepted, or false if canceled.

DismissAsync

Dismisses the top-most active modal presentation layer.

Task DismissAsync()

Returns

  • Task: A task representing the async operation.

OpenUrlAsync

Opens a web address in an in-app Safari browser, with the system reader, share and done chrome.

Task OpenUrlAsync(
  string url)
ParameterSummary
string urlThe http or https address to open.

Returns

  • Task: A task that completes once the browser is presented.

OpenUrlAsync

Opens a web address in an in-app Safari browser with custom presentation and browser options.

Task OpenUrlAsync(
  string url,
  ModalStyle style,
  bool entersReaderIfAvailable = false,
  bool barCollapsingEnabled = true,
  SafariDismissButtonStyle dismissButtonStyle = Close)
ParameterSummary
string urlThe http or https address to open.
ModalStyle styleThe modal style and sheet detents used to present the browser.
(optional) bool entersReaderIfAvailableWhether Safari should enter Reader mode when it is available.
(optional) bool barCollapsingEnabledWhether Safari's bars may collapse while browsing.
(optional) SafariDismissButtonStyle dismissButtonStyleThe style of the browser's dismiss button.

Returns

  • Task: A task that completes once the browser is presented.

PopAsync

Pops the top page off the current navigation stack.

Task PopAsync()

Returns

  • Task: A task representing the async operation.

PopToRootAsync

Pops all pages off the stack except for the root page.

Task PopToRootAsync()

Returns

  • Task: A task representing the async operation.

PresentAsync

Presents a modal page, resolving its ViewModel from the service container.

Task PresentAsync<TViewModel>(
  ModalStyle style) where TViewModel : class
ParameterSummary
ModalStyle styleThe modal style and presentation configuration.
Type parameterSummary
(class) TViewModelThe type of the ViewModel to resolve.

Returns

  • Task: A task representing the async operation.

PresentAsync

Presents a modal page using an existing ViewModel instance.

Task PresentAsync(
  object viewModel,
  ModalStyle style)
ParameterSummary
object viewModelThe ViewModel instance to bind to the page.
ModalStyle styleThe modal style and presentation configuration.

Returns

  • Task: A task representing the async operation.

PresentAsync

Presents a modal page, resolving its ViewModel by type from the service container.

Task PresentAsync(
  Type viewModel,
  ModalStyle style)
ParameterSummary
Type viewModelThe type of the ViewModel to resolve.
ModalStyle styleThe modal style and presentation configuration.

Returns

  • Task: A task representing the async operation.

PresentViewAsync

Presents a registered view, resolving any associated ViewModel from the service container.

Task PresentViewAsync<TView>(
  ModalStyle style) where TView : ContentView
ParameterSummary
ModalStyle styleThe modal style and presentation configuration.
Type parameterSummary
ContentView TViewThe registered view type.

Returns

  • Task: A task representing the async operation.

PresentViewAsync

Presents an existing page instance directly.

Create a new instance per navigation.

Task PresentViewAsync(
  ContentView page,
  ModalStyle style)
ParameterSummary
ContentView pageThe page to present.
ModalStyle styleThe modal style and presentation configuration.

Returns

  • Task: A task representing the async operation.

PresentViewAsync

Presents a registered view by type, resolving any associated ViewModel from the service container.

Task PresentViewAsync(
  Type view,
  ModalStyle style)
ParameterSummary
Type viewThe registered view type.
ModalStyle styleThe modal style and presentation configuration.

Returns

  • Task: A task representing the async operation.

PromptAsync

Displays an alert with a single text field, for a name or another short answer.

Task<string?> PromptAsync(
  string title,
  string message,
  string placeholder = "",
  string text = "",
  string accept = "OK",
  string cancel = "Cancel",
  bool destructive = false)
ParameterSummary
string titleThe title text of the alert.
string messageThe message body.
(optional) string placeholderThe text field's placeholder.
(optional) string textThe text the field starts with.
(optional) string acceptThe text for the confirming button.
(optional) string cancelThe text for the canceling button.
(optional) bool destructiveWhether the confirming button is styled as destructive.

Returns

  • Task<string?>: A task containing what was typed, or null if the alert was canceled.

PushAsync

Pushes a new page onto the stack, resolving its ViewModel from the service container.

Task PushAsync<TViewModel>() where TViewModel : class
Type parameterSummary
(class) TViewModelThe type of the ViewModel to resolve.

Returns

  • Task: A task representing the async operation.

PushAsync

Pushes a new page onto the stack using an existing ViewModel instance.

Task PushAsync(
  object viewModel)
ParameterSummary
object viewModelThe ViewModel instance to bind to the page.

Returns

  • Task: A task representing the async operation.

PushAsync

Pushes a new page onto the stack, resolving its ViewModel by type from the service container.

Task PushAsync(
  Type viewModel)
ParameterSummary
Type viewModelThe type of the ViewModel to resolve.

Returns

  • Task: A task representing the async operation.

PushViewAsync

Pushes a registered view, resolving any associated ViewModel from the service container.

Task PushViewAsync<TView>() where TView : ContentView
Type parameterSummary
ContentView TViewThe registered view type.

Returns

  • Task: A task representing the async operation.

PushViewAsync

Pushes an existing page instance directly.

Create a new instance per navigation.

Task PushViewAsync(
  ContentView page)
ParameterSummary
ContentView pageThe page to push.

Returns

  • Task: A task representing the async operation.

PushViewAsync

Pushes a registered view by type, resolving any associated ViewModel from the service container.

Task PushViewAsync(
  Type view)
ParameterSummary
Type viewThe registered view type.

Returns

  • Task: A task representing the async operation.

SelectAsync

Displays an action sheet layout with individually styled choices.

Task<string?> SelectAsync(
  string title,
  string cancel = "Cancel",
  params DialogOption[] options)
ParameterSummary
string titleThe action sheet's title.
(optional) string cancelThe cancel button's text.
DialogOption optionsThe options to choose from.

Returns

  • Task<string?>: A task containing the chosen option's text, or null if the action sheet was canceled.

SelectTabAsync

Selects the tab with the given title, as declared on Tab(title, ...).

Task SelectTabAsync(
  string title)
ParameterSummary
string titleThe tab's title.

Returns

  • Task: A task representing the async operation.