diff --git a/src/Maui/Prism.Maui/Navigation/PageNavigationService.cs b/src/Maui/Prism.Maui/Navigation/PageNavigationService.cs index f682df7a32..e61137dca7 100644 --- a/src/Maui/Prism.Maui/Navigation/PageNavigationService.cs +++ b/src/Maui/Prism.Maui/Navigation/PageNavigationService.cs @@ -2,6 +2,7 @@ using System.Web; using Prism.Common; using Prism.Events; +using Prism.Extensions; using Prism.Mvvm; using Application = Microsoft.Maui.Controls.Application; using XamlTab = Prism.Navigation.Xaml.TabbedPage; @@ -1333,6 +1334,47 @@ public virtual async Task NavigateFromAsync(string viewName, /// public virtual async Task NavigateFromAsync(string viewName, Uri route, INavigationParameters parameters) { - throw new NotImplementedException(); + await _semaphore.WaitAsync(); + // Ensure adequate time has passed since last navigation so that UI Refresh can Occur + if (DateTime.Now - _lastNavigate < TimeSpan.FromMilliseconds(150)) + { + await Task.Delay(150); + } + + try + { + if (parameters is null) + parameters = new NavigationParameters(); + + NavigationSource = PageNavigationSource.NavigationService; + + var routeSegments = UriParsingHelper.GetUriSegments(route); + + var page = GetPageFromWindow(); + if(page is not null && ViewModelLocator.GetNavigationName(page) == viewName) + { + await ProcessNavigation(page, routeSegments, parameters, null, true); + } + else + { + var viewNameSegment = new Queue(); + viewNameSegment.Enqueue(viewName); + var navigationSegments = new Queue(viewNameSegment.Concat(routeSegments)); + + await ProcessNavigationForAbsoluteUri(routeSegments, parameters, null, true); + } + + return Notify(route, parameters); + } + catch (Exception ex) + { + return Notify(route, parameters, ex); + } + finally + { + _lastNavigate = DateTime.Now; + NavigationSource = PageNavigationSource.Device; + _semaphore.Release(); + } } }