コード例 #1
0
        public static void GoTo <TViewModel>(this NavigateHelper <TViewModel> uriBuilder)
        {
            var navigationService = IoC.Get <INavigationService>();

            uriBuilder.Navigate();
            while (navigationService.BackStack.Count > 0)
            {
                navigationService.BackStack.RemoveAt(0);
            }
        }
コード例 #2
0
        public static void Navigate <TViewModel>(this NavigateHelper <TViewModel> uriBuilder, INavigationService navigationService, Action <TViewModel> action) where TViewModel : class
        {
            NavigatedEventHandler navigationServerOnNavigated = null;

            navigationServerOnNavigated = (s, e) =>
            {
                var viewModel = ViewModelLocator.LocateForView(e.Content) as TViewModel;
                if (viewModel != null)
                {
                    action(viewModel);
                }
                navigationService.Navigated -= navigationServerOnNavigated;
            };

            navigationService.Navigated += navigationServerOnNavigated;
            uriBuilder.Navigate();
        }
コード例 #3
0
        /// <summary>
        /// 重定向页面
        /// </summary>
        public static void Redirect <TViewModel>(this NavigateHelper <TViewModel> navigateHelper, bool animated = true)
        {
            //获取导航页
            NavigationPage navigationPage = ResolveMediator.Resolve <NavigationPage>();

            //获取导航前页面
            IList <Page> prevPages = new List <Page>(navigationPage.Navigation.NavigationStack);

            //导航至新页面
            navigateHelper.Navigate(animated);

            //移除导航前页面
            foreach (Page prevPage in prevPages)
            {
                navigationPage.Navigation.RemovePage(prevPage);
            }
        }