After item reorder CollectionChanged gives wrong new index sometimes

5 posts, 0 answers
  1. Vitaly
    Vitaly avatar
    6 posts
    Member since:
    Oct 2012

    Posted 18 Sep Link to this post

    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

  2. JM
    JM avatar
    7 posts
    Member since:
    Sep 2017

    Posted 18 Sep in reply to Vitaly Link to this post

    I have the same issue
  3. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1236 posts

    Posted 20 Sep Link to this post

    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
  4. Vitaly
    Vitaly avatar
    6 posts
    Member since:
    Oct 2012

    Posted 20 Sep in reply to Pavel R. Pavlov Link to this post

    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

  5. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1236 posts

    Posted 20 Sep Link to this post

    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
Back to Top