How to find the child image on SfListView

Under c# code, I want to get a child imageview under SfListView, is there a way to accomplish that?

1 Reply 1 reply marked as answer

SS SaiGanesh Sakthivel Syncfusion Team September 21, 2020 11:30 AM UTC

Hi John,  
  
Thank you for contacting syncfusion support.  
  
We have checked the reported query “How to find the child image on SfListView” from our end. We would like to inform you that you can achieve your requirement by using TapGestureRecognizer for Grid to get the child of the listview. Please refer to the following code snippet for your reference.  
  
<Grid x:Name="grid" RowSpacing="0">  
   <Grid.GestureRecognizers> 
   <TapGestureRecognizer  Command="{Binding Path=BindingContext.ItemTappedCommand,                            Source={x:Reference listView}}" CommandParameter="{Binding ContactImage}}"/> 
   </Grid.GestureRecognizers> 
    <Image Source="{Binding ContactImage}"  
VerticalOptions="Center"  
HorizontalOptions="Center"  
HeightRequest="50" WidthRequest="50"/>  
</Grid>  
  
C#  
ItemTappedCommand to get the tapped item  
public Command ItemTappedCommand  
 
    get { return itemTappedCommand; }  
    protected set { itemTappedCommand = value; }  
}
..
public
ContactsViewModel() 
 
 
    contactsinfo = new ObservableCollection<Contacts>();  
    itemTappedCommand = new Command(OnItemTapped);  
    GenerateInfo();  
}
…. 
 

private
void OnItemTapped(object obj) 
{ 
    var itemData = (obj as ImageSource); 
} 
  
We hope this helps. Please let us know if you need any further assistance.  
  
Regards,  
SaiGanesh Sakthivel

Marked as answer
Loader.
Up arrow icon