SfListView Do not let select any element

Hello:
I Have a list of a objects where I have declared the multiselection, well the thing is that I want to know if there is any way that Ican prevent the user from selecting some objects, for example: If my program consists of articles with a stock, I just want the user can select the items that have stock, those that are 0 that can nor be selected.
Would there by any way to do it?
Thank you so much

5 Replies

MK Muthu Kumaran Gnanavinayagam Syncfusion Team February 14, 2018 01:00 PM UTC

Hi Maria, 
 
We have checked your requirement “Need to handle touch for particular list items” from our side. We would like to inform you that you can achieve your requirement using ItemTapped event in SfListView. You can get the data of the tapped item from the ItemData of ItemTappedEventArgs. Then based on your requirement, you can check the condition and handle the touch action for that item as like below. 
 
Code Example[C#]: 
private void listView_ItemTapped(object sender, Syncfusion.ListView.XForms.ItemTappedEventArgs e) 
{ 
  if ((e.ItemData as StockModel).Stock > 0) 
  { 
    e.Handled = true; 
  } 
} 
 
For your reference, we have attached the sample and you can download it from the below link 
 
 
Regards, 
G.Muthu kumaran. 



MA Maria February 14, 2018 03:19 PM UTC

Hello:

Thank you very much, it was just what I needed.




MK Muthu Kumaran Gnanavinayagam Syncfusion Team February 15, 2018 04:11 AM UTC

Hi Maria, 
 
Thanks for your valuable response. 
 
Regards, 
G.Muthu kumaran. 



AJ Allyson José December 17, 2018 02:59 PM UTC

Hi,

How can I do this using MVVM in my ViewModel?

Thanks.


GP Gnana Priya Namasivayam Syncfusion Team December 18, 2018 12:40 PM UTC

Hi Allyson, 
  
Thanks for using Syncfusion product. 
 
We have checked your reported query from our side. We have UG documentation to achieve your requirement in item tapped event using MVVM in view model, please find the below UG link for your reference below. 
 
 
Please let us know if you require any further assistance.  
 
Regards, 
Gnana Priya N. 
 


Loader.
Up arrow icon