Tap gesture not working inside tooltip template

Hi,
I was trying to give tap gesture inside a tool tip template but it was not working. Below is the code snippet:

<chart:ColumnSeries.TooltipTemplate>
                            <DataTemplate x:Name="template">
                                <Frame WidthRequest="120" BindingContext="NewPageViewModel" VerticalOptions="FillAndExpand" Padding="0" HasShadow="true" BorderColor="Transparent">
                                   
                                    <StackLayout Spacing="0">
                                    <ListView x:Name="list" ItemsSource="{Binding CanceledList}" RowHeight="45" SeparatorColor="#e9e9e9" >                                       
                                        <ListView.ItemTemplate>
                                            <DataTemplate>
                                                <ViewCell>
                                                 <StackLayout Orientation="Horizontal" >
                                                                                    <Image Source="dotInfo.png" WidthRequest="15" 
                                                                                           HeightRequest="15"
                                                                                           Margin="5,8,0,0"
                                                                                           VerticalOptions="Start" 
                                                                                           HorizontalOptions="Start" />
                                                                                    <StackLayout Orientation="Vertical" Spacing="0">
                                                                                        <StackLayout Orientation="Horizontal">
                                                                                            <Label Text="{Binding FlightName}" Margin="0,5,0,0" FontSize="Small" FontAttributes="Bold"></Label>
                                                                                            <Label Text="{Binding FlightNo}" Margin="0,5,0,0" FontSize="Small"></Label>
                                                                                        </StackLayout>
                                                                                        <StackLayout Orientation="Horizontal">
                                                                                            <Label Text="{Binding Guests} " FontSize="Small"></Label>
                                                                                            <Label Text="Guests" FontSize="Small"></Label>
                                                                                        </StackLayout>
                                                                                       
                                                                                    </StackLayout>
                                                                                </StackLayout>
                                                </ViewCell>
                                            </DataTemplate>
                                        </ListView.ItemTemplate>
                                    </ListView>
                                      
                                     <Button Text="View Flights"
                                             
                                                                      TextColor="#2774AE"
                                                                      HeightRequest="30"
                                                                      FontSize="Small"
                                             Command="{Binding ViewFlightsCommand}"
                                            BackgroundColor="Maroon"
                                                                      VerticalOptions="FillAndExpand"
                                                                      HorizontalOptions="FillAndExpand" 
                                                                     >
                                           
                                          <!--  <Label.GestureRecognizers>
                                                <TapGestureRecognizer Command="{Binding ViewFlightsCommands}"/> 
                                            </Label.GestureRecognizers>-->
                                      </Button>
                                            
                                           
                                  </StackLayout>
                                </Frame>
                            </DataTemplate>
                        </chart:ColumnSeries.TooltipTemplate>

The tap gesture is currently commented in the above code. I have tried with label and button, none of them are working.

1 Reply

MP Michael Prabhu M Syncfusion Team September 24, 2018 12:33 PM UTC

Hi Sweety, 
 
Greetings from Syncfusion, we have analyzed your code snippet and we like to let you know by default the binding context for Tooltip Template is the Model class and not the ViewModel. If you want to set the binding context as a ViewModel then you can set the parent as Viewmodel as like in below code snippet.  
 
Code snippet C# 
public class ViewModel 
{ 
    public ICommand LabelCommand { get; set; } 
 
    public ViewModel() 
         
    { 
        LabelCommand = new Command(LabelSelected); 
    } 
 
    private void LabelSelected(object obj) 
    { 
    } 
} 
 
public class Model 
{ 
    public ViewModel Parent { get; set; } 
    public Model(ViewModel viewModel) 
    { 
       Parent = viewModel; 
    } 
} 
 
 
 
Code Snippet[XAML]  
 
  <Label Text="label" HorizontalTextAlignment="Center" VerticalTextAlignment="Center"> 
      <Label.GestureRecognizers> 
            <TapGestureRecognizer Command="{Binding Parent.LabelCommand}"  ></TapGestureRecognizer> 
      </Label.GestureRecognizers> 
</Label> 
 
 
Based on this we have prepared a simple sample and it can be downloaded from the link below. 
 
 
Thanks, 
Michael  



Loader.
Up arrow icon