Binding Commands for items in syncfusion:SfListView

I want to bind the Command property of in image TapGestureRecognizer to a command in the viewModel of the view:
so I made this:

                                    <Image.GestureRecognizers>
                                        <TapGestureRecognizer Tapped="Vote_Tapped" Command="{Binding Path=BindingContext.OnVotingCommand, Source={x:Reference stkMain}}" CommandParameter="{Binding id}"/>
                                    </Image.GestureRecognizers>
the stkMain is the container of the page, 
but it doesn't work.


here's the ItemTemplate:

<syncfusion:SfListView.ItemTemplate>
                        <DataTemplate>
                            <AbsoluteLayout Margin="10" VerticalOptions="Start" HorizontalOptions="FillAndExpand" BackgroundColor="Orange">
                                <StackLayout VerticalOptions="Start" AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All">
                                    <Image Source="{Binding image}" Aspect="Fill">
                                        <Image.GestureRecognizers>
                                            <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" CommandParameter="{Binding}"/>
                                        </Image.GestureRecognizers>
                                    </Image>
                                    <BoxView HeightRequest="30" HorizontalOptions="FillAndExpand"/>
                                </StackLayout>
                                <Image Source="{Helper:ImageResourceExtension PrinseSultan.images.misc.like-line.png}" AbsoluteLayout.LayoutBounds="0.5,1,80,40"  AbsoluteLayout.LayoutFlags="PositionProportional">
                                    <Image.GestureRecognizers>
                                        <TapGestureRecognizer Tapped="Vote_Tapped" Command="{Binding Path=BindingContext.OnVotingCommand, Source={x:Reference stkMain}}" CommandParameter="{Binding id}"/>
                                    </Image.GestureRecognizers>
                                </Image>
                                <!--<Button Text="Upvote" Command="{Binding Path=BindingContext.OnVotingCommand, Source={x:Reference stkMain}}" CommandParameter="{Binding id}" x:Name="btnVote" AbsoluteLayout.LayoutBounds="0.5,1,80,40"  AbsoluteLayout.LayoutFlags="PositionProportional"/>-->
                                <!--<Image/>-->
                            </AbsoluteLayout>
                        </DataTemplate>
                    </syncfusion:SfListView.ItemTemplate>

1 Reply

MK Muthu Kumaran Gnanavinayagam Syncfusion Team December 4, 2017 01:36 PM UTC

Hi Mohamed, 
 
We have checked with the reported query “Need to bind Command for SfListView items” from our side. We are glad to let you know that we have already published KB documentation to meet your requirement. Please refer the below link for the same. 
 
 
Please let us know if you require further assistance. 
 
Regards, 
G.Muthu Kumaran. 


Loader.
Up arrow icon