microsoft-ui-xaml icon indicating copy to clipboard operation
microsoft-ui-xaml copied to clipboard

ListView reorder item triggers ObservableCollection Remove and Add instead of Move

Open HHaoWang opened this issue 9 months ago • 1 comments

Describe the bug

It seems to be a history problem but it still confusing me that reorder item doesn't trigger ObservableCollection.Move method. I want to detect if some item is reordered, however I can not find any solution. Default ListView reordering behavior is remove item from the ObservableCollection and then add item to the ObservableCollection. Hence I can not determine whether item is reorder or add/remove. It's so weird. Is there any solution to detect reordering?

Steps to reproduce the bug

  1. Place a ListView with a ObservableCollection ItemSource and enable ListView reorder ability
  2. Add event handler to the ObservableCollection's CollectionChanged
  3. Reorder item in ListView and CollectionChanged was triggered twice. One is remove event and the other is add event.

Expected behavior

ObservableCollection's CollectionChanged should be triggered only once with NotifyCollectionChangedAction=Move

Screenshots

No response

NuGet package version

None

Windows version

No response

Additional context

No response

HHaoWang avatar May 30 '24 15:05 HHaoWang