如何实现Xamarin Forms TableView单元格中单击的行?

如何实现Xamarin Forms TableView单元格中单击的行?,xamarin,xamarin.forms,Xamarin,Xamarin.forms,我在XAML中为Xamarin表单设置了以下tableview: <TableView Intent="Menu"> <TableRoot> <TableSection Title="Categories"> <ViewCell> <StackLayout Orientation="Horizontal" VerticalOptions="Center" Padding="20,0,

我在XAML中为Xamarin表单设置了以下tableview:

<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>


有人能告诉我如何实现单击行以打开另一个内容页xamarin forms吗?或者我必须在iOS端单独实现吗?

请查看有关的Xamarin文档

您也可以在这里应用该方法。 我不完全确定您是否可以将其直接应用于
ViewCell
,但您应该可以在
StackLayout
上进行

所以它会是这样的:

<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>


然后当然要实现事件方法。

请查看有关事件的Xamarin文档

您也可以在这里应用该方法。 我不完全确定您是否可以将其直接应用于
ViewCell
,但您应该可以在
StackLayout
上进行

所以它会是这样的:

<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>


然后当然实现事件方法。

您还可以将点击的方法添加到ViewCell本身

像这样:

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


然后在代码隐藏中编写句柄\单元格\事件处理程序

您还可以将Tapped方法添加到ViewCell本身

像这样:

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

然后在代码隐藏中编写句柄\单元格\事件处理程序