microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.21k stars 669 forks source link

ListView reorder item triggers ObservableCollection Remove and Add instead of Move #9685

Open HHaoWang opened 2 months ago

HHaoWang commented 2 months ago

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

github-actions[bot] commented 2 months ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

fabianoriccardi commented 1 week ago

I can confirm this issue, that, IMHO, is a bug and not a feature request.

Which developer would think that a reordering gesture triggers a couple of add-remove notifications instead of a Move one?

HHaoWang commented 1 week ago

I can confirm this issue, that, IMHO, is a bug and not a feature request.

Which developer would think that a reordering gesture triggers a couple of add-remove notifications instead of a Move one?

I cannot agree it more