Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ private Control GetRecycledOrCreateElement(IReadOnlyList<TItem> items, int index
if (e.GetVisualParent() is null)
{
((ISetLogicalParent)e).SetParent(this);
LogicalChildren.Add(e);
VisualChildren.Add(e);
}
return e;
Expand Down Expand Up @@ -729,6 +730,21 @@ private void TrimUnrealizedChildren()
}
}
}

var logicalChildren = LogicalChildren;

if (logicalChildren.Count > count)
{
for (var i = logicalChildren.Count - 1; i >= 0; --i)
{
var child = logicalChildren[i];

if (child is Visual { IsVisible: false })
{
logicalChildren.RemoveAt(i);
}
}
}
}

private void OnItemsCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
base.OnApplyTemplate(e);
CellsPresenter = e.NameScope.Find<TreeDataGridCellsPresenter>("PART_CellsPresenter");

if (CellsPresenter is { })
{
LogicalChildren.Add(CellsPresenter);
}

if (RowIndex >= 0)
CellsPresenter?.Realize(RowIndex);
}
Expand Down
10 changes: 9 additions & 1 deletion src/Avalonia.Controls.TreeDataGrid/TreeDataGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,16 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
}

base.OnApplyTemplate(e);
ColumnHeadersPresenter = e.NameScope.Find<TreeDataGridColumnHeadersPresenter>("PART_ColumnHeadersPresenter");
ColumnHeadersPresenter =
e.NameScope.Find<TreeDataGridColumnHeadersPresenter>("PART_ColumnHeadersPresenter");
RowsPresenter = e.NameScope.Find<TreeDataGridRowsPresenter>("PART_RowsPresenter");

if (ColumnHeadersPresenter is { })
LogicalChildren.Add(ColumnHeadersPresenter);

if(RowsPresenter is { })
LogicalChildren.Add(RowsPresenter);

Scroll = e.NameScope.Find<ScrollViewer>("PART_ScrollViewer");
_headerScroll = e.NameScope.Find<ScrollViewer>("PART_HeaderScrollViewer");

Expand Down