How to enable and disable Swiping for particular items in SFListView control?

In the SFListView we have to set AllowSwiping=true for getting swipe view actions. ​

But when I'm trying to enable or disable based on the condition for particular item in list its not working. 

I'm checking like this:

<listview:SfListView
Grid.Row="0"
x:Name="_attachmentListView"
HorizontalOptions="Fill"
ItemsSource="{Binding Attachments}"
VerticalOptions="Fill"
ScrollBarVisibility="Always"
SwipeThreshold="50"
SwipeOffset="100"
SelectionMode="None"
AutoFitMode="Height">

<listview:SfListView.AllowSwiping>
<MultiBinding Converter="{StaticResource IsMultiValueAllTrueConverter}">
<Binding Source="{x:Reference _attachmentCollectionControl}" Path="IsEditable" />
<Binding Path="UserHasAccess" />
</MultiBinding>
</listview:SfListView.AllowSwiping>

</listview:SfListView>


Though both values are true it does not show the Swipe. It only works if I set it directly like AllowSwiping=true

5 Replies

SY Suthi Yuvaraj Syncfusion Team May 6, 2024 08:14 AM UTC

Hi Divyesh Bhatt,

We have checked your requirement , you can cancel the swiping for a particular item in SwipeStarting event , Please refer the below documentation for more reference.

UG Link: https://help.syncfusion.com/maui/listview/swiping#swipestarting-event

Kindly let us know if you have any concerns

Regards,

Suthi Yuvaraj.



DB Divyesh Bhatt May 9, 2024 06:40 AM UTC

Hi Suthi, 

I've check the SwipeStarting and it does work. Can we convert this event to command using EventToCommandBehavior of maui community toolkit? If yes, how? 

I have tried to use EventToCommandBehavior of maui community toolkit but not getting e.cancle in that. 



SY Suthi Yuvaraj Syncfusion Team May 9, 2024 03:48 PM UTC

Divyesh Bhatt,

We have checked your requirement , you can convert the SwipeStarting event to command by EventToCommand behavior. we have attached the sample which explains about to convert event to command.

We have attached the documentation which explains about passing parameter for command 

KB Link:https://support.syncfusion.com/kb/article/15545/how-to-pass-the-item-data-as-command-parameter-in-itemtapped-command-in-net-maui-listview

Please let us know if you have any concerns.


Attachment: MauiListView_d719ee3c.zip


DB Divyesh Bhatt May 9, 2024 05:43 PM UTC

This you have provided for ItemTapped, I want EventToCommandBehavior for SwipeStarting Event. Because I have to disable swipe based on conditions. 

If I follow the way ItemTapped command implemented, in object I will not get both IsEditTable and eventArgs DataItem. 



SY Suthi Yuvaraj Syncfusion Team May 10, 2024 01:10 PM UTC

Divyesh Bhatt,

We would like to let you we have attached the KB link for your reference as you can pass the parameter to command in EventToCommand behavior, but we have created a sample for your requirement. Please have a look at the sample and let us know if you have any concerns.


Loader.
Up arrow icon