Converters not updating when items in listview are reordered

Hello,


I have an SfListView filled with items. Each item has a box view above it to act as a separator between the items. I have a converter checking if the item is the first item in the sflistview. If so, it sets the IsVisible property of the box view to false and every other one that is not the first item is set to true.


The problem happens when I drag any item to the first item in the list. When I do this, the new first item (the one that I just moved to the top) has the box view set to false (which is the correct scenario). But the old first item, which is now moved to the second item, still has the box views is visible's property set to false. It needs to be visible since it is now not the first item in the list.


It fixes itself right when I start to drag an item again. It also works correctly if I move the first item out of the first position.


Any help would be greatly appreciated.


Thanks,


David


6 Replies

LN Lakshmi Natarajan Syncfusion Team August 31, 2021 06:53 AM UTC

Hi David, 
 
Thank you for using Syncfusion products. 
 
We have checked the reported query “Converters not updating when items in listview are reordered” from our side. We would like to let you know that the converter will be called when the bound property is updated. We do not update the binding when reordering, so the converter is not called. This is the expected behavior in Xamarin. 
 
Also, you can achieve your requirement by refreshing the items after reordering. The SfListView.ItemDragging event is triggered after reordering the item and update the separate line using the RefreshListViewItem method in the DropAction.Drop action. You need to set the UpdateSource property as true, to update the collection after reordering.  
 
Please refer to our online documentation to update the separator line after reordering from the following link, 
 
Please let us know if you need further assistance. 
 
Regards, 
Lakshmi Natarajan 



DB David Bauer August 31, 2021 08:01 PM UTC

Hello,


Thank you for the quick reply. The above solution does not work. I implemented it to refresh the item on the drop event.


If I move an item to the top of the list, that separator updates correctly. However, when it pushes the previous first item down. That item's separator does not update.


I have tried to refresh all of the items as well and that did not work.


Any help would be appreciated.


Thanks,


David



LN Lakshmi Natarajan Syncfusion Team September 1, 2021 10:04 AM UTC

Hi David, 
 
Sorry for the inconvenience caused. 
 
You can overcome the reported scenario “when it pushes the previous first item down, the item's separator does not update” by calling the RefreshListViewItem as mentioned below, 
 
private void ListView_ItemDragging(object sender, ItemDraggingEventArgs e) 
{ 
    if (e.Action == DragAction.Drop) 
    { 
        if (e.OldIndex > e.NewIndex) 
        { 
            Device.BeginInvokeOnMainThread(() => ListView.RefreshListViewItem(e.NewIndex, e.OldIndex, true)); 
        } 
        else 
        { 
            Device.BeginInvokeOnMainThread(() => ListView.RefreshListViewItem(e.OldIndex, e.NewIndex, true)); 
        } 
    } 
} 
 
 
Also, we will update the changes in our documentation as soon as possible.  
 
Please let us know if you need further assistance. 
 
Lakshmi Natarajan 
  
 



JJ jacky joy September 1, 2021 01:21 PM UTC

thanks for the awesome information.



LN Lakshmi Natarajan Syncfusion Team September 2, 2021 05:04 AM UTC

Hi Jacky, 
 
Thank you for the update. 
 
We are glad that our solution meets your requirement. Please let us know if you need any further assistance. As always we are happy to help you out. 
 
Lakshmi Natarajan 
 



JJ jacky joy March 23, 2022 02:10 PM UTC


Loader.
Up arrow icon