PrismLibrary/Prism · error · ArgumentNullException
navigationCallback
Error message
navigationCallback
What it means
RequestNavigate validates that the completion callback is non-null before starting navigation, because the NavigationResult must be delivered back to the caller. A null callback makes the asynchronous navigation result unobservable, so Prism throws immediately rather than navigating silently.
Solutions
- Pass a non-null callback, even a no-op: result => { }.
- In helper wrappers, substitute an empty lambda when the caller supplies none.
- Guard the callback at the call site before invoking RequestNavigate.
Example fix
// before
navigationService.RequestNavigate(new Uri("DetailsView", UriKind.Relative), null);
// after
navigationService.RequestNavigate(new Uri("DetailsView", UriKind.Relative), result => { }); Defensive patterns
Strategy: try-catch
Validate before calling
if (navigationCallback is null)
navigationCallback = result => { };
navigationService.RequestNavigate(target, navigationCallback, parameters); Type guard
bool HasCallback(Action<NavigationResult> cb) => cb is not null;
Try / catch
try
{
navigationService.RequestNavigate(target, result => OnNavigated(result));
}
catch (ArgumentNullException)
{
// supply a callback and retry
} Prevention
- Always pass a result handler lambda, even an empty one.
- Wrap navigation in a helper that substitutes a no-op callback.
- Treat Action<NavigationResult> parameters as required, not optional.
When it happens
Trigger: Calling region.NavigationService.RequestNavigate(uri, null) or forwarding a callback variable that is null (e.g. an unassigned Action<NavigationResult>).
Common situations: Wrapping navigation in helper methods with an optional callback parameter that is passed straight through; refactoring that dropped the callback lambda.
Related errors
AI-assisted analysis of PrismLibrary/Prism@358118cd64 (2026-09-15).
Data as JSON: /api/errors/5e6fc6c4167c0f46.
Report an issue: GitHub.
Appendix: source
Thrown at src/Maui/Prism.Maui/Navigation/Regions/Navigation/RegionNavigationService.cs:91
/// Initiates navigation to the specified target.
/// </summary>
/// <param name="target">The target.</param>
/// <param name="navigationCallback">A callback to execute when the navigation request is completed.</param>
public void RequestNavigate(Uri target, Action<NavigationResult> navigationCallback)
{
RequestNavigate(target, navigationCallback, null);
}
/// <summary>
/// Initiates navigation to the specified target.
/// </summary>
/// <param name="target">The target.</param>
/// <param name="navigationCallback">A callback to execute when the navigation request is completed.</param>
/// <param name="regionParameters">The navigation parameters specific to the navigation request.</param>
public void RequestNavigate(Uri target, Action<NavigationResult> navigationCallback, INavigationParameters regionParameters)
{
if (navigationCallback == null)
throw new ArgumentNullException(nameof(navigationCallback));
try
{
DoNavigate(target, navigationCallback, regionParameters);
}
catch (Exception e)
{
NotifyNavigationFailed(new NavigationContext(this, target), navigationCallback, e);
}
}
private void DoNavigate(Uri source, Action<NavigationResult> navigationCallback, INavigationParameters regionParameters)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
if (Region == null)
throw new InvalidOperationException(Resources.NavigationServiceHasNoRegion);View on GitHub (pinned to 358118cd64)