I have a complex page layout: <ContentPage.Content> <StackLayout > <ScrollView > <FlexLayout BindableLayout.ItemsSource=""> <BindableLayout.ItemTemplate> <DataTemplate> <components:SomeComponent /> </DataTemplate> </BindableLayout.ItemTemplate> </FlexLayout> </ScrollView> </StackLayout> </ContentPage.Content> Then there is component definition: <StackLayout xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml x:Class="XXX.Components. SomeComponent"> <AbsoluteLayout> ..... </AbsoluteLayout> <StackLayout.GestureRecognizers> <TapGestureRecognizer Command="{Binding BindingContext.GoToDetailCommand}" CommandParameter="{Binding SomeID}"/> </StackLayout.GestureRecognizers> </StackLayout> In my case I am unable to fire Tap gesture. I suspect that FlexLayout BindableLayout.ItemsSource="{Binding XXX}" is binding to specific observable collection, so in component Binding BindingContext.GoToDetailCommand actually does not exist (they are defined in initial viewmodel for this page). Can you please advise how to sort this issue? Dino
Answers
Firstly, name your component layout like:
And then change the binding like:
We could retrieve the parent
FlexLayout
that is located on the page through the parent property. Therefore, its binding context could also be accessed.