|
1 | 1 | using Avalonia;
|
2 | 2 | using Avalonia.Controls;
|
| 3 | +using Avalonia.Controls.Primitives; |
3 | 4 | using Avalonia.Media;
|
4 | 5 | using Avalonia.VisualTree;
|
5 | 6 |
|
@@ -51,26 +52,40 @@ public override void Render(DrawingContext context)
|
51 | 52 | if (histories == null)
|
52 | 53 | return;
|
53 | 54 |
|
54 |
| - var list = histories.CommitListContainer; |
55 |
| - if (list == null) |
| 55 | + var grid = histories.CommitListContainer; |
| 56 | + if (grid == null) |
56 | 57 | return;
|
57 | 58 |
|
58 |
| - var container = list.ItemsPanelRoot as VirtualizingStackPanel; |
59 |
| - if (container == null) |
| 59 | + var rowsPresenter = grid.FindDescendantOfType<DataGridRowsPresenter>(); |
| 60 | + if (rowsPresenter == null) |
60 | 61 | return;
|
61 | 62 |
|
62 |
| - var item = list.ContainerFromIndex(container.FirstRealizedIndex); |
63 |
| - if (item == null) |
64 |
| - return; |
| 63 | + double rowHeight = grid.RowHeight; |
| 64 | + double startY = 0; |
| 65 | + foreach (var child in rowsPresenter.Children) |
| 66 | + { |
| 67 | + var row = child as DataGridRow; |
| 68 | + if (row.IsVisible) |
| 69 | + { |
| 70 | + if (rowHeight != row.Bounds.Height) |
| 71 | + rowHeight = row.Bounds.Height; |
| 72 | + |
| 73 | + if (row.Bounds.Top <= 0 && row.Bounds.Top > -rowHeight) |
| 74 | + { |
| 75 | + var test = rowHeight * row.Index - row.Bounds.Top; |
| 76 | + if (startY < test) |
| 77 | + startY = test; |
| 78 | + } |
| 79 | + } |
| 80 | + } |
65 | 81 |
|
66 |
| - var width = histories.CommitListHeader.ColumnDefinitions[0].ActualWidth; |
67 |
| - var height = Bounds.Height; |
68 |
| - var rowHeight = item.Bounds.Height; |
69 |
| - var startY = container.FirstRealizedIndex * rowHeight - item.TranslatePoint(new Point(0, 0), list).Value!.Y; |
| 82 | + var headersHeight = grid.ColumnHeaderHeight; |
| 83 | + var width = histories.CommitListContainer.Columns[0].ActualWidth; |
| 84 | + var height = Bounds.Height - headersHeight; |
70 | 85 | var endY = startY + height + 28;
|
71 | 86 |
|
72 |
| - using (context.PushClip(new Rect(0, 0, width, height))) |
73 |
| - using (context.PushTransform(Matrix.CreateTranslation(0, -startY))) |
| 87 | + using (context.PushClip(new Rect(0, headersHeight, width, height))) |
| 88 | + using (context.PushTransform(Matrix.CreateTranslation(0, headersHeight - startY))) |
74 | 89 | {
|
75 | 90 | DrawCurves(context, graph, startY, endY, rowHeight);
|
76 | 91 | DrawAnchors(context, graph, startY, endY, rowHeight);
|
|
0 commit comments