示例#1
0
        private async Task <NavigationResult> PeekPreviousRegion(INavigationParameters parameters)
        {
            var result = new NavigationResult();

            try
            {
                var currentRegion = PagesContainer[NavigationHistory.Pop()];

                var canNavigate = await PageUtilities.CanNavigateAsync(currentRegion, parameters);

                if (!canNavigate)
                {
                    result.Exception = new Exception(NavigationException.IConfirmNavigationReturnedFalse);
                    return(result);
                }

                if (NavigationHistory.Count == 0)
                {
                    //TODO: exit the application.
                    //_applicationProvider..Quit();
                    result.Success = true;
                    return(result);
                }

                var previousRegion = PagesContainer[NavigationHistory.Peek()];
                GetContentPresenter().Content = previousRegion;

                PageUtilities.OnNavigatedFrom(currentRegion, parameters);
                PageUtilities.OnNavigatedTo(previousRegion, parameters);

                if (CurrentRegionName.Contains('/'))
                {
                    PopRegion(currentRegion);
                }
                CurrentRegionName = NavigationHistory.Peek();

                result.Success = true;
                return(result);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                result.Exception = ex;
                return(result);
            }
        }