protected override Size MeasureOverride(Size availableSize) { BuildSpanGraph(); // 频繁增删Children子元素会出现卡顿现象! // Children = _rows + _recycledRows RowLayoutModel rowLayoutModel = GetRowLayoutModel(); int less = rowLayoutModel.Count - Children.Count; if (less > 0) { for (int i = 0; i < less; i++) { HeaderItem rowItem = new HeaderItem(this); Children.Add(rowItem); _recycledRows.Add(rowItem); } } // 先回收不可见行 List <HeaderItem> rows = _rows.Values.ToList(); foreach (var rowItem in rows) { RowLayout layout = rowLayoutModel.FindRow(rowItem.Row); if (layout == null || layout.Height <= 0.0) { _recycledRows.Add(rowItem); _rows.Remove(rowItem.Row); rowItem.Row = -1; } } double x = Location.X; double y = Location.Y; double maxWidth = 0.0; foreach (RowLayout layout in rowLayoutModel) { if (layout.Height <= 0.0) { continue; } bool updateAllCell = false; HeaderItem rowItem = null; if (!_rows.TryGetValue(layout.Row, out rowItem)) { // 重新利用回收的行 rowItem = _recycledRows[0]; _recycledRows.RemoveAt(0); rowItem.Row = layout.Row; _rows.Add(layout.Row, rowItem); updateAllCell = true; } rowItem.UpdateChildren(updateAllCell); int z = rowItem.ContainsSpanCell ? _spanRowZIndexBase + rowItem.Row : _normalZIndexBase + rowItem.Row; z = z % 0x7ffe; Canvas.SetZIndex(rowItem, z); rowItem.Location = new Point(x, y); // 测量尺寸足够大,否则当单元格占多行时在uno上只绘一行! rowItem.Measure(availableSize); y += layout.Height; maxWidth = Math.Max(maxWidth, rowItem.DesiredSize.Width); } // 测量回收的行 if (_recycledRows.Count > 0) { foreach (var rowItem in _recycledRows) { rowItem.Measure(_szEmpty); } } return(new Size(maxWidth + Location.X, y)); }
public RowHeaderCell(HeaderItem p_rowItem) : base(p_rowItem) { }
public ColHeaderCell(HeaderItem p_rowItem) : base(p_rowItem) { }