示例#1
0
        public void GotoPage(int key)
        {
            CurrentPage?.OnNavigatedFrom(false);

            WizardPageViewModel nextPage;

            if (Pages.TryGetValue(key, out nextPage))
            {
                NavigationHistory.Push(CurrentPageKey);
                CurrentPage    = nextPage;
                CurrentPageKey = key;

                CurrentPage?.OnNavigatedTo(true);
            }

            // TODO: Handle this
        }
示例#2
0
        private async Task <NavigationResult> PushRegion(string path, INavigationParameters parameters)
        {
            var result = new NavigationResult();

            try
            {
                View currentRegion = null;
                parameters = GetParams(path, parameters);

                if (PagesContainer.Count > 0)
                {
                    currentRegion = PagesContainer.Last().Value;
                    var canNavigate = await PageUtilities.CanNavigateAsync(currentRegion, parameters);

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

                View nextRegion = null;
                if (path.Contains('/'))
                {
                    foreach (var splitPath in path.Split(new[] { '/' },
                                                         StringSplitOptions.RemoveEmptyEntries))
                    {
                        if (PagesContainer.Keys.Contains(splitPath))
                        {
                            continue;
                        }
                        nextRegion = _containerProvider.ResolveRegion(splitPath);
                        PagesContainer.Add(splitPath, nextRegion);
                    }
                }
                else if (PagesContainer.Keys.Contains(path))
                {
                    nextRegion = PagesContainer[path];
                }
                else
                {
                    nextRegion = _containerProvider.ResolveRegion(path);
                    PagesContainer.Add(path, nextRegion);
                }

                GetContentPresenter().Content = nextRegion;

                await PageUtilities.OnInitializedAsync(currentRegion, parameters);

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

                CurrentRegionName = path;
                NavigationHistory.Push(CurrentRegionName);

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