0
votes

I have the following tableview set up in XAML for Xamarin Forms:

<TableView Intent="Menu">
   <TableRoot>
      <TableSection Title="Categories">
         <ViewCell>
            <StackLayout Orientation="Horizontal" VerticalOptions="Center" Padding="20,0,20,0">
               <Label Text="Category" XAlign="Center"/>
               <Label Text=">" HorizontalOptions="EndAndExpand" XAlign="Center"/>
            </StackLayout>
        </ViewCell>
      </TableSection>
   </TableRoot> 
</TableView>

Can anyone let me know how to implement the clicking of the row to open another content page xamarin forms? Or do I have to separately implement in the iOS side?

2

2 Answers

2
votes

Have a look at the Xamarin Documentation about the TapGestureRecognizer.

You can apply that method here as well. I'm not completely sure if you can apply it directly to the ViewCell but you should be able to do it on the StackLayout.

So it would be something like:

<TableView Intent="Menu">
   <TableRoot>
      <TableSection Title="Categories">
         <ViewCell>
            <StackLayout Orientation="Horizontal" VerticalOptions="Center" Padding="20,0,20,0">
               <StackLayout.GestureRecognizers>
                   <TapGestureRecognizer
                       Tapped="OnTapGestureRecognizerTapped"
                       NumberOfTapsRequired="1" />
               </StackLayout.GestureRecognizers>

               <Label Text="Category" XAlign="Center"/>
               <Label Text=">" HorizontalOptions="EndAndExpand" XAlign="Center"/>
            </StackLayout>
        </ViewCell>
      </TableSection>
   </TableRoot> 
</TableView>

And then of course implement the event method.

2
votes

You could also add the Tapped method to the ViewCell itself.

Like this:

<ViewCell Tapped="Handle_Cell_Tapped">
</View>

Then write your Handle_Cell_Tapped event handler in the code behind.