public static string GetNavigationPath(this INavigationService service, bool includeParameters) { var nav = service as IPlatformNavigationService2; var facade = nav.FrameFacade as IFrameFacade2; var sb = new List <string>(); foreach (var item in facade.Frame.BackStack) { if (PageRegistry.TryGetRegistration(item.SourcePageType, out var info)) { if (item.Parameter != null) { if (includeParameters) { sb.Add($"{info.Key}?{item.Parameter}"); } else { sb.Add(info.Key); } } else { sb.Add(info.Key); } } } sb.Add(facade.CurrentNavigationPath); return($"/{string.Join("/", sb.ToArray())}"); }
public NavigationPath(int index, string originalString, INavigationParameters parameters) { Index = index; _originalString = originalString; // parse name/key Key = originalString.Split('?').First(); // parse query var queryString = originalString.Split('?').Last(); if (queryString != Key) { QueryString = queryString; } // parse parameters if (!string.IsNullOrEmpty(QueryString)) { var query = new WwwFormUrlDecoder(QueryString); foreach (var item in query) { Parameters.Add(item.Name, item.Value); } } // merge parameters if (parameters != null) { foreach (var item in parameters) { Parameters.Add(item.Key, item.Value); } } // get types if (PageRegistry.TryGetRegistration(Key, out var info)) { Key = info.Key; View = info.View; ViewModel = info.ViewModel; } else { throw new Exception($"Count not find Key:[{Key}]. Use RegisterTypes()/container.RegisterForNavigation<T, T>()."); } }
public static string GetNavigationPath(this INavigationService service) { var nav = service as IPlatformNavigationService2; var facade = nav.FrameFacade as IFrameFacade2; var sb = new List <string>(); foreach (var item in facade.Frame.BackStack) { if (PageRegistry.TryGetRegistration(item.SourcePageType, out var info)) { sb.Add(info.Key); } } return(string.Join("/", sb.ToArray())); }