protected override System.Windows.Size ArrangeOverride(System.Windows.Size finalSize)
        {
            if (Element == null || finalSize.Width * finalSize.Height == 0)
            {
                return(finalSize);
            }

            Element.IsInNativeLayout = true;

            if (Control != null)
            {
                Control.Measure(finalSize);
                Control.Arrange(new Rect(0, 0, finalSize.Width, finalSize.Height));
            }

            for (var i = 0; i < Element.LogicalChildren.Count; i++)
            {
                var child = Element.LogicalChildren[i] as VisualElement;
                if (child == null)
                {
                    continue;
                }
                IVisualElementRenderer renderer = Platform.GetRenderer(child);
                if (renderer == null)
                {
                    continue;
                }
                Rectangle bounds = child.Bounds;

                renderer.ContainerElement.Arrange(new Rect(bounds.X, bounds.Y, Math.Max(0, bounds.Width), Math.Max(0, bounds.Height)));
            }

            Element.IsInNativeLayout = false;

            return(finalSize);
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
0
 public static IVisualElementRenderer GetRenderer(this VisualElement self)
 {
     return(Platform.GetRenderer(self));
 }