Myra icon indicating copy to clipboard operation
Myra copied to clipboard

Bug: NotifyCollectionChangedAction.Reset not cleaning up items

Open minimalism opened this issue 4 years ago • 3 comments

ObservableCollection implements a Clear method that calls CollectionChanged callback with a NotifyCollectionChangedEventArgs where the action is NotifyCollectionChangedAction.Reset. This case isn't implemented in ComboBox.Items_CollectionChanged, Menu.ItemsOnCollectionChanged or Grid.OnProportionsChanged (But probably should be, note how for example FileDialog.UpdateFolder calls _gridFiles.RowsProportions.Clear() in FileDialog.cs) In MultipleItemsContainerBase.cs and Desktop.cs this case is implemented but due to how the ChildrenCopy property works, the removed items will not have their desktop and parent unset.

minimalism avatar Sep 07 '20 18:09 minimalism

Thanks for reporting. I've fixed this case for Menu & ComboBox. As for Grid.OnProportionsChanged, it calls InvalidateMeasure, which is enough. I dont think any additional processing in required there.

I'll look further into removed items not having Parent and Desktop unset.

rds1983 avatar Nov 10 '20 18:11 rds1983

In MultipleItemsContainerBase.cs and Desktop.cs this case is implemented but due to how the ChildrenCopy property works, the removed items will not have their desktop and parent unset.

It works for me: image

rds1983 avatar Nov 12 '20 16:11 rds1983

I can confirm this is also happening with ListBox Items collections.

Nornec avatar Oct 29 '21 00:10 Nornec