Exemplo n.º 1
0
        void UpdateRootPage(IReadOnlyList <Page> stack)
        {
            Page first = stack.FirstOrDefault();

            if (first == _currentRoot)
            {
                return;
            }

            if (Children.Count > 0)
            {
                var renderer = Children[0] as IVisualElementRenderer;
                if (renderer != null)
                {
                    Children.RemoveAt(0);

                    var page = renderer.Element as IPageController;
                    if (page != null)
                    {
                        page.IgnoresContainerArea = false;
                    }

                    if (!stack.Contains(renderer.Element))
                    {
                        Platform.SetRenderer(renderer.Element, null);
                    }
                }
            }

            _currentRoot = first;

            if (first == null)
            {
                return;
            }

            ((IPageController)first).IgnoresContainerArea = true;

            IVisualElementRenderer firstRenderer = Platform.GetRenderer(first);

            if (firstRenderer == null)
            {
                firstRenderer = Platform.CreateRenderer(first);
                Platform.SetRenderer(first, firstRenderer);
            }
            var    uiElement = (UIElement)firstRenderer;
            var    platform  = Element.Platform as Platform;
            Canvas canvas    = platform?.GetCanvas();

            //We could be swapping the visible page,
            //so let's make sure we remove it
            if (canvas.Children.Contains(uiElement))
            {
                canvas.Children.Remove(uiElement);
            }
            Children.Add(uiElement);

            // we removed the previous root page, and the new root page is the one being presented
            // at this time there's only 1 page now on the stack (the navigationpage with root)
            // we need to update the platform to set this root page as the visible again
            bool updateRoot = Element.CurrentPage == first && _isRemoving;

            if (updateRoot)
            {
                platform.SetCurrent(Element, false);
            }
        }
Exemplo n.º 2
0
 public static IVisualElementRenderer GetRenderer(VisualElement view)
 {
     return(Platform.CreateRenderer(view));
 }