public virtual void GoForward()
 {
     if (!CrystalApplication.GetCurrentAsCrystalApplication().Options.HandleForwardNavigationStack)
     {
         throw new InvalidOperationException("HandleForwardNavigationStack is set to false.");
     }
 }
示例#2
0
        internal NavigationManager(CrystalApplication appInstance)
        {
            if (appInstance == null)
            {
                throw new ArgumentNullException("appInstance");
            }

            AppInstance = appInstance;
        }
        private void NavigationFrame_Navigated(object sender, NavigationEventArgs e)
        {
            if (e.NavigationMode == NavigationMode.Back)
            {
                //so the following line (view in git history) seems to point out a possible bug. when using inline navigation, the inline-page's datacontext reverts to the datacontext of the frame's parent.
                //... mo-code, mo-problems - we create a new instance to solve that problem.
                //TODO implement event/hook for injecting cached viewmodels

                //ViewModelBase lastViewModel = default(ViewModelBase);
                if (lastViewModel != null)
                {
                    lastViewModel.OnNavigatedFrom(sender, new CrystalNavigationEventArgs(e)
                    {
                        Direction = ConvertToCrystalNavDirections(e.NavigationMode)
                    });

                    if (CrystalApplication.GetCurrentAsCrystalApplication().Options.HandleForwardNavigationStack)
                    {
                        viewModelForwardStack.Push(lastViewModel);
                    }
                }

                if (viewModelBackStack.Count > 0)
                {
                    var viewModel = viewModelBackStack.Pop();


                    InvokePreNavigatedEvent(new NavigationServicePreNavigatedSignaledEventArgs(viewModel, new CrystalNavigationEventArgs(e)));


                    if (viewModel == null)
                    {
                        throw new Exception();
                    }

                    ((Page)e.Content).DataContext = viewModel;

                    viewModel.OnNavigatedTo(this, new CrystalNavigationEventArgs(e)
                    {
                        Direction = ConvertToCrystalNavDirections(e.NavigationMode)
                    });

                    lastViewModel = viewModel;
                }
                else
                {
                    HandleTerminationReload(e);
                }

                InvokeNavigatedEvent(new CrystalNavigationEventArgs(e)
                {
                    Direction = ConvertToCrystalNavDirections(e.NavigationMode)
                });

                navigationLock.Set();
            }
        }