Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[android] CollectionView logical children grows with Header/Footer
Fixes: dotnet#16961 Debugging the `ItemsSourceDoesNotLeak()` test with a new `Header` and `Footer` on Android, there was some very odd behavior... At the end of the test, `_logicalChildren` contained 9 items! Header Footer Header Footer Header null null null Footer Where I would expect it to contain 5?!? It appears the problem is: * `CollectionView.ItemsSource` changes * We notify Android's `RecyclerView` to refresh * `RecyclerView` calls `OnCreateViewHolder()` for the header, footer, and all rows. * `CreateHeaderFooterViewHolder()` is called again for the header & footer. * Duplicate `viewHolder.View` items are added as logical children. To fix this, an idea: * Create a new `internal ContainsLogicalChild()` method * Call this before adding the same `View` in `CreateHeaderFooterViewHolder()` This isn't the *best*, because it will iterate over the `_logicalChildren` to decide if the list contains the view. But this is better than what strange behavior might result from this?
- Loading branch information