2016-09-01 9 views
0

私はXamarinフォームのXAMLで設定し、次のテーブルビューを持っている:Xamarin Forms 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フォームを開くために、行のクリックを実装する方法を知っていることはできますか?それとも、iOS側に別途実装する必要がありますか?

答えて

2

TapGestureRecognizerについての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> 

そしてもちろんイベントメソッドを実装します。

だから、のようなものになるでしょう。

+1

ありがとうございました! –

関連する問題