This is a migrated thread and some comments may be shown as answers.

After item reorder CollectionChanged gives wrong new index sometimes

4 Answers 92 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Vitaly
Top achievements
Rank 1
Vitaly asked on 18 Sep 2017, 10:11 AM

Hello,

 

When reorder is enabled via IsItemsReorderEnabled ListView calls CollectionChanged event for underlying ObservableCollection.

But in some cases it reports wrong new index and though visually item order is as expected underlying ObservableCollection gets wrong order.

 

To reproduce the issue bind just 2 strings to the ListView, say Item1 and Item2.

Drag first string (Item1) under second (Item2), ListView will look like this:

Item2

Item1

 

But ObservableCollection still has this:

Item1 (wrong!)

Item2 (wrong!)

If you subscribe to CollectionChanged event you will see that reported new item index is wrong, it should be 1 but in fact it is 0, as if the item was moved from 0 to 0.

 

Now start over, then drag second item (Item2) on top of first item (Item1), ListView will look like this:

Item2

Item1

 

And ObservableCollection properly updated to:

Item2 (correct)

Item1 (correct)

 

It looks like when an item is moved down its index is less by 1 than it should be.

Please check.

 

Yours faithfully

Vitaly Knyazev

4 Answers, 1 is accepted

Sort by
0
JM
Top achievements
Rank 1
answered on 18 Sep 2017, 10:45 AM
I have the same issue
0
Pavel R. Pavlov
Telerik team
answered on 20 Sep 2017, 10:26 AM
Hello Vitaly & JM,

We tested the reported behavior on our side and indeed the reorder does not work as expected when two items are visible. This is why we logged a bug report in our feedback portal. Please give your vote for it since every vote counts and can lead to further increasing the priority of the issue.

At the mite of writing we are not aware of a workaround. We will post a solution if we are able to find one, before providing a fix.

Regards,
Pavel R. Pavlov
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Vitaly
Top achievements
Rank 1
answered on 20 Sep 2017, 11:25 AM

Hi Pavel,

 

Thank you for raising the bug, but its description is a bit misleading.

This issue occurs also when more that 2 items are in the list, I used 2 items example only to highlight the issue.

If you have 10 or 1000 of items and drag an item from top to bottom its index is wrong by 1.

If you drag an item from bottom to top its index is ok.

 

Cheers

Vitaly

0
Pavel R. Pavlov
Telerik team
answered on 20 Sep 2017, 12:01 PM
Hi Vitaly,

Yes. I noticed that and I mentioned it in the internal item but I exposed the public item like it was reported. The actual bug occurs when reordering adjacent items, no matter their position.

Regards,
Pavel R. Pavlov
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
ListView
Asked by
Vitaly
Top achievements
Rank 1
Answers by
JM
Top achievements
Rank 1
Pavel R. Pavlov
Telerik team
Vitaly
Top achievements
Rank 1
Share this question
or