Exemplo n.º 1
0
        public static IVisualElementRenderer GetOrCreateRenderer(this VisualElement bindable)
        {
            var renderer = XFPlatform.GetRenderer(bindable);

            if (renderer == null)
            {
                renderer = XFPlatform.CreateRenderer(bindable);
                XFPlatform.SetRenderer(bindable, renderer);
            }
            return(renderer);
        }
Exemplo n.º 2
0
        nfloat CalculateHeightForCell(NSTableView tableView, Cell cell)
        {
            var    viewCell = cell as ViewCell;
            double renderHeight;

            if (List.RowHeight == -1 && viewCell?.View != null)
            {
                var target = viewCell.View;
                if (_prototype == null)
                {
                    _prototype = Platform.CreateRenderer(target);
                    Platform.SetRenderer(target, _prototype);
                }
                else
                {
                    _prototype.SetElement(target);
                    Platform.SetRenderer(target, _prototype);
                }

                var req = target.Measure(tableView.Frame.Width, double.PositiveInfinity, MeasureFlags.IncludeMargins);

                target.ClearValue(Platform.RendererProperty);
                foreach (var descendant in target.Descendants())
                {
                    descendant.ClearValue(Platform.RendererProperty);
                }

                renderHeight = req.Request.Height;
            }
            else
            {
                renderHeight = cell.RenderHeight;
            }

            return(renderHeight > 0 ? (nfloat)renderHeight : ListViewRenderer.DefaultRowHeight);
        }
        void UpdateControllers()
        {
            ClearControllers();

            if (Platform.GetRenderer(MasterDetailPage.Master) == null)
            {
                Platform.SetRenderer(MasterDetailPage.Master, Platform.CreateRenderer(MasterDetailPage.Master));
            }
            if (Platform.GetRenderer(MasterDetailPage.Detail) == null)
            {
                Platform.SetRenderer(MasterDetailPage.Detail, Platform.CreateRenderer(MasterDetailPage.Detail));
            }

            AddSplitViewItem(new NSSplitViewItem
            {
                ViewController = new ViewControllerWrapper(Platform.GetRenderer(MasterDetailPage.Master))
            });
            AddSplitViewItem(new NSSplitViewItem
            {
                ViewController = new ViewControllerWrapper(Platform.GetRenderer(MasterDetailPage.Detail))
            });

            UpdateChildrenLayout();
        }