Search This Blog

Sunday 14 March 2021

How Pass Parameters to Tap Gesture Xamarin Forms

 Design Side : 

<Grid RowDefinitions="Auto" ColumnDefinitions="*,20">
        <Label Grid.Row="0" Text="Test Label"  TextColor="Gray" />
        <Grid.GestureRecognizers>
            <TapGestureRecognizer  CommandParameter="{Binding .}"  Tapped="TapGestureRecognizer_Tapped_SelectOption" />
        </Grid.GestureRecognizers>
</Grid>
Code Behind: 
private async void TapGestureRecognizer_Tapped_SelectOption(object sender, EventArgs e)
{
      var tapEventArgs = (TappedEventArgs)e;
      var parameter =   (ClassName) tapEventArgs.Parameter;
      //ClassName : Type Of Object That Going to return from CommandParameter
}
 

No comments:

Post a Comment

Popular Posts