コード例 #1
0
        public Size MeasureOverrideHorizontal(IStackBase stack, Size constraint)
        {
            //var padding = panelStack.Padding;

            double measuredWidth  = 0;
            double measuredHeight = 0;

            IUICollection <IUIElement> children = stack.Children;
            int count = stack.Children.Count;

            for (int i = 0; i < count; i++)
            {
                IUIElement child = children[i];
                if (!child.Visible)
                {
                    continue;
                }

                child.Measure(new Size(double.PositiveInfinity, constraint.Height));
                var desiredSize = child.DesiredSize;
                measuredWidth += desiredSize.Width;
                measuredHeight = Math.Max(measuredHeight, desiredSize.Height);
            }

            measuredWidth += MeasureTotalSpacing(stack);
            //measuredWidth += padding.HorizontalThickness;
            //measuredHeight += padding.VerticalThickness;

            var finalWidth  = ResolveWidthConstraints(stack, constraint.Width, measuredWidth);
            var finalHeight = ResolveHeightConstraints(stack, constraint.Height, measuredHeight);

            return(new Size(finalWidth, finalHeight));
        }
コード例 #2
0
            private void MeasureCells()
            {
                for (int n = 0; n < _cells.Length; n++)
                {
                    var cell = _cells[n];

                    if (cell.ColumnGridLengthType == GridLengthType.Pixel &&
                        cell.RowGridLengthType == GridLengthType.Pixel)
                    {
                        continue;
                    }

                    double availableWidth  = AvailableWidth(cell);
                    double availableHeight = AvailableHeight(cell);

                    IUIElement child = _childrenToLayOut[cell.ChildIndex];

                    if (cell.IsColumnSpanAuto || cell.IsRowSpanAuto || cell.MeasureStarAsAuto)
                    {
                        child.Measure(new Size(availableWidth, availableHeight));
                        var measure = child.DesiredSize;

                        if (cell.IsColumnSpanAuto)
                        {
                            if (cell.ColumnSpan == 1)
                            {
                                _columns[cell.Column].Update(measure.Width);
                            }
                            else
                            {
                                var span = new Span(cell.Column, cell.ColumnSpan, true, measure.Width);
                                TrackSpan(span);
                            }
                        }

                        if (cell.IsRowSpanAuto)
                        {
                            if (cell.RowSpan == 1)
                            {
                                _rows[cell.Row].Update(measure.Height);
                            }
                            else
                            {
                                var span = new Span(cell.Row, cell.RowSpan, false, measure.Height);
                                TrackSpan(span);
                            }
                        }
                    }
                }

                ResolveSpans();

                ResolveStarColumns();
                ResolveStarRows();

                EnsureFinalMeasure();
            }