protected override Size MeasureVirRows() { // 列头 _colHeader.Measure(new Size(_maxSize.Width - _topLeftWidth, _maxSize.Height)); _topLeft.Measure(new Size(_topLeftWidth, _colHeader.DesiredSize.Height)); double height = _colHeader.DesiredSize.Height; // 超过宽度时水平滚动 double maxWidth = Math.Max(_maxSize.Width, _owner.Cols.TotalWidth + _topLeftWidth); // 数据行 if (_dataRows.Count > 0) { // 重新测量 Size testSize = new Size(maxWidth, _rowHeight); // 表格时始终重置宽度,若只在创建时确定列宽,造成调整列宽时不一致! _finalWidth = 0; foreach (var row in _dataRows) { row.Measure(testSize); if (row.DesiredSize.Width > _finalWidth) { _finalWidth = row.DesiredSize.Width; } } } height += _rowHeight * _owner.Rows.Count; // 分组行 Size size = new Size(_finalWidth, _maxSize.Height); if (_owner.GroupRows != null) { double top = 0; foreach (var grp in _owner.GroupRows) { grp.Top = top; grp.Measure(size); height += grp.DesiredSize.Height; top += grp.DesiredSize.Height; top += grp.Data.Count * _rowHeight; } } // 分组导航头,出现垂直滚动栏时才显示 if (_groupHeader != null && height > _maxSize.Height) { _groupHeader.Measure(size); height += _groupHeader.DesiredSize.Height; // 增加高度使最底部分组能够滚动到顶部,确保和导航位置同步! var group = _owner.GroupRows[_owner.GroupRows.Count - 1]; double delta = _maxSize.Height - _colHeader.DesiredSize.Height - _groupHeader.DesiredSize.Height - group.DesiredSize.Height - group.Data.Count * _rowHeight; // 因uno加1 if (delta > 0) { height += delta + 1; } } return(new Size(_finalWidth, height)); }