Example #1
0
        public void NavigationInfoIsNullForUnregisteredPage()
        {
            var name = "UnRegisteredPage";
            var info = PageNavigationRegistry.GetPageNavigationInfo(name);

            Assert.Null(info);
        }
Example #2
0
        private static Page ProcessCurrentPageNavigationPath(Page page, Stack <string> stack)
        {
            var    currentPageKeyInfo = PageNavigationRegistry.GetPageNavigationInfo(page.GetType());
            string currentSegment     = $"{currentPageKeyInfo.Name}";

            var parent = page.Parent as Page;

            if (parent != null)
            {
                var parentKeyInfo = PageNavigationRegistry.GetPageNavigationInfo(parent.GetType());

                if (parent is TabbedPage || parent is CarouselPage)
                {
                    //set the selected tab to the current page
                    currentSegment = $"{parentKeyInfo.Name}?{KnownNavigationParameters.SelectedTab}={currentPageKeyInfo.Name}";
                    page           = parent;
                }
                else if (parent is MasterDetailPage)
                {
                    currentSegment = $"{parentKeyInfo.Name}/{currentPageKeyInfo.Name}";
                    page           = parent;
                }
            }

            stack.Push(currentSegment);

            return(page);
        }
Example #3
0
        public void RegisterPageForNavigation()
        {
            PageNavigationRegistry.ClearRegistrationCache();

            var name = "MainPage";
            var type = typeof(PageMock);

            PageNavigationRegistry.Register(name, type);

            var info = PageNavigationRegistry.GetPageNavigationInfo(name);

            Assert.NotNull(info);
        }
Example #4
0
        private static void AddSegmentToStack(Page page, Stack <string> stack)
        {
            if (page == null)
            {
                return;
            }

            var keyInfo = PageNavigationRegistry.GetPageNavigationInfo(page.GetType());

            if (keyInfo != null)
            {
                stack.Push(keyInfo.Name);
            }
        }
Example #5
0
            private void OnCurrentItemChanged(object sender, CurrentItemChangedEventArgs e)
            {
                if (sender is CarouselView carousel && carousel.CurrentItem != CurrentView && carousel.CurrentItem != null && carousel.CurrentItem is VisualElement newActiveView)
                {
                    var previousView = CurrentView;
                    CurrentView = newActiveView;

                    if (!_region.ActiveViews.Contains(newActiveView))
                    {
                        _region.Activate(newActiveView);
                    }

                    var info    = PageNavigationRegistry.GetPageNavigationInfo(newActiveView.GetType());
                    var context = new NavigationContext(_region.NavigationService, new Uri(info.Name, UriKind.RelativeOrAbsolute));

                    MvvmHelpers.OnNavigatedFrom(previousView, context);
                    MvvmHelpers.OnNavigatedTo(newActiveView, context);
                }
            }