Avalonia.Controls.TreeDataGrid icon indicating copy to clipboard operation
Avalonia.Controls.TreeDataGrid copied to clipboard

TreeDataGridPresenterBase Replace Regression

Open xLEGiON opened this issue 11 months ago • 0 comments

Pull request https://github.com/AvaloniaUI/Avalonia.Controls.TreeDataGrid/pull/241 ported some fixes from https://github.com/AvaloniaUI/Avalonia/pull/13795 to RealizedStackElements, including the new ItemsReplaced method. It also made use of this more efficient method in TreeDataGridPresenterBase when the items collection changed with a NotifyCollectionChangedAction.Replace action.

However, this made the assumption that the old and new items of the NotifyCollectionChangedEventArgs have the same length. When this is not true (e.g. replacing 2 items with 1 or 3 items), the TreeDataGrid does not display the collection change correctly. Before this change to TreeDataGridPresenterBase, the collection change was displayed correctly.

To fix this, it is still possible to use the more efficient ItemsReplaced method when the old and new items have the same length, but use the previous behavior when they do not. I've tested this idea and it fixes the issue. I will create a pull request with the proposed change.

Environment: TreeDataGrid Version: 11.0.2 Avalonia Version: 11.0.6 Operating System: Windows 10

xLEGiON avatar Feb 26 '24 14:02 xLEGiON