/* * Navigate<T> allows developers to navigate using a * page key instead of the view type. This is accomplished by * creating a custom Enum and setting up the PageKeys dict * with the Key/Type pairs for your views. The dict is * shared by all NavigationServices and is stored in * the BootStrapper (or Application) of the app. * * Implementation example: * * // define your Enum * public Enum Pages { MainPage, DetailPage } * * // setup the keys dict * var keys = BootStrapper.PageKeys<Views>(); * keys.Add(Pages.MainPage, typeof(Views.MainPage)); * keys.Add(Pages.DetailPage, typeof(Views.DetailPage)); * * // use Navigate<T>() * NavigationService.Navigate(Pages.MainPage); */ // T must be the same custom Enum used with BootStrapper.PageKeys() public bool Navigate <T>(T key, object parameter = null, NavigationTransitionInfo infoOverride = null) where T : struct, IConvertible { var keys = BootStrapper.Current.PageKeys <T>(); if (!keys.ContainsKey(key)) { throw new KeyNotFoundException(key.ToString()); } var page = keys[key]; if (page.FullName.Equals(LastNavigationType) && parameter == LastNavigationParameter) { return(false); } return(FrameFacade.Navigate(page, parameter, infoOverride)); }
public bool Navigate(Type page, object parameter = null, NavigationTransitionInfo infoOverride = null) { if (page == null) { throw new ArgumentNullException(nameof(page)); } if (page.FullName.Equals(LastNavigationType)) { if (parameter == LastNavigationParameter) { return(false); } if (parameter != null && parameter.Equals(LastNavigationParameter)) { return(false); } } parameter = SerializePageParam(parameter); return(FrameFacade.Navigate(page, parameter, infoOverride)); }