示例#1
0
        void EnsureRowsColumnsInitialized()
        {
            _columns = ColumnDefinitions == null ? new List <ColumnDefinition>() : ColumnDefinitions.ToList();
            _rows    = RowDefinitions == null ? new List <RowDefinition>() : RowDefinitions.ToList();

            int lastRow = -1;

            for (var index = 0; index < InternalChildren.Count; index++)
            {
                Element w = InternalChildren[index];
                lastRow = Math.Max(lastRow, GetRow(w) + GetRowSpan(w) - 1);
            }
            lastRow = Math.Max(lastRow, RowDefinitions.Count - 1);

            int lastCol = -1;

            for (var index = 0; index < InternalChildren.Count; index++)
            {
                Element w = InternalChildren[index];
                lastCol = Math.Max(lastCol, GetColumn(w) + GetColumnSpan(w) - 1);
            }
            lastCol = Math.Max(lastCol, ColumnDefinitions.Count - 1);

            while (_columns.Count <= lastCol)
            {
                _columns.Add(new ColumnDefinition());
            }
            while (_rows.Count <= lastRow)
            {
                _rows.Add(new RowDefinition());
            }

            for (var index = 0; index < _columns.Count; index++)
            {
                ColumnDefinition col = _columns[index];
                col.ActualWidth = -1;
            }
            for (var index = 0; index < _rows.Count; index++)
            {
                RowDefinition row = _rows[index];
                row.ActualHeight = -1;
            }
        }