示例#1
0
        public virtual void PlayReverse(Action completed)
        {
            TransitionHelper.Hide(ToPage);
            TransitionHelper.Show(FromPage);

            if (completed != null)
            {
                completed.Invoke();
            }
        }
示例#2
0
        public void GoTo <TPage, TTransition>(Object parameter, bool includeInBackStack = true)
            where TPage : PageBase
            where TTransition : PageTransition, new()
        {
            PageBase page;

            if (CurrentPage != null && CurrentPage.GetType() == typeof(TPage))
            {
                CurrentPage.NavigatedTo(NavigationMode.Refresh, parameter);
                NavigationClearer();
                return;
            }
            //OnNavigating();
            if (CurrentPage != null)
            {
                CurrentPage.IsHitTestVisible = false;
                CurrentPage.NavigatedFrom(NavigationMode.Forward);
                page = GetPage <TPage>();


                page.BeforeNavigateTo();
                var transition = Activator.CreateInstance <TTransition>();

                transition.FromPage = CurrentPage;
                transition.ToPage   = page;
                transition.Play(() =>
                {
                    CurrentPage           = page;
                    page.IsHitTestVisible = true;
                    var from = _rootContainer.Children.IndexOf(page);
                    var to   = _rootContainer.Children.Count - 1;

                    _rootContainer.Children.Move((uint)from, (uint)to);

                    page.NavigatedTo(NavigationMode.Forward, parameter);
                    _rootPage.BottomAppBar = page.Bar;
                    //OnNavigated();
                });

                if (includeInBackStack || _stack.Count > 0)
                {
                    PageTransition navTransition = null;
                    if (!includeInBackStack)
                    {
                        navTransition        = _stack.Pop().Invoke(false);
                        navTransition.ToPage = transition.ToPage;
                    }
                    else
                    {
                        navTransition = transition;
                    }
                    Commit(
                        execute =>
                    {
                        if (!execute)
                        {
                            return(transition);
                        }

                        navTransition.PlayReverse(
                            () =>
                        {
                            CurrentPage = navTransition.FromPage;

                            var from = _rootContainer.Children.IndexOf(navTransition.FromPage);
                            var to   = _rootContainer.Children.Count - 1;

                            _rootContainer.Children.Move((uint)from, (uint)to);

                            _rootPage.BottomAppBar = navTransition.FromPage.Bar;
                            navTransition.ToPage.NavigatedFrom(NavigationMode.Back);
                            navTransition.ToPage.IsHitTestVisible = false;
                            navTransition.FromPage.NavigatedTo(NavigationMode.Back, null);
                            navTransition.FromPage.IsHitTestVisible = true;
                        });
                        return(transition);
                    });
                    NavigationClearer();
                    return;
                }
            }
            page = GetPage <TPage>();


            page.IsHitTestVisible = true;
            page.BeforeNavigateTo();

            TransitionHelper.Show(page);

            CurrentPage            = page;
            _rootPage.BottomAppBar = page.Bar;

            var fromMain = _rootContainer.Children.IndexOf(page);
            var toMain   = _rootContainer.Children.Count - 1;

            _rootContainer.Children.Move((uint)fromMain, (uint)toMain);
            page.NavigatedTo(NavigationMode.Forward, parameter);


            //OnNavigated();
        }