コード例 #1
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            TablePanel tablePanel = this.GetVisualAncestors().OfType <TablePanel>().FirstOrDefault();
            double     minWidth   = 0;
            // TODO - use ColumnMinWidth / quantify
            int columnCount = 0;
            var widths      = tablePanel != null ? tablePanel.CurrentWidths : null;

            foreach (UIElement child in Children)
            {
                var width = child.DesiredSize.Width;
                if (widths != null && widths.Count > columnCount)
                {
                    width = widths[columnCount];
                }
                var newWidth = Math.Max(0, Math.Min(finalSize.Width - minWidth, width));
                child.Arrange(new Rect(minWidth, 0, newWidth, finalSize.Height));
                minWidth += newWidth;
                columnCount++;
            }
            return(new Size(minWidth, finalSize.Height));
        }
コード例 #2
0
        protected override Size MeasureOverride(Size availableSize)
        {
            TablePanel tablePanel = this.GetVisualAncestors().OfType <TablePanel>().FirstOrDefault();

            double minHeight = MinHeight;
            double minWidth  = 0;

            int columnCount = 0;

            foreach (UIElement child in Children)
            {
                child.Measure(availableSize);
                var width = child.DesiredSize.Width;
                if (tablePanel != null && tablePanel.MinWidths.Count > columnCount)
                {
                    tablePanel.MinWidths[columnCount] = Math.Max(tablePanel.MinWidths[columnCount], width);
                }
                minWidth += width;
                minHeight = Math.Max(minHeight, child.DesiredSize.Height);
                columnCount++;
            }
            return(new Size(Math.Max(minWidth, MinWidth), minHeight));
        }