我有这个代码。我想用<Grid>
替换它并简化它。有没有办法可以做到这一点并实现GestureRecognizer
?
<ViewCell x:Name="cfs">
<StackLayout VerticalOptions="CenterAndExpand" Padding="20,0,20,0">
<StackLayout.GestureRecognizers>
<TapGestureRecognizer Command="{Binding OpenPickerCommand}" CommandParameter="{x:Reference cfsPicker}" NumberOfTapsRequired="1" />
</StackLayout.GestureRecognizers>
<StackLayout Orientation="Horizontal" VerticalOptions="CenterAndExpand">
<StackLayout HorizontalOptions="StartAndExpand" VerticalOptions="Center">
<local:LabelBodyRendererClass Text="Card Front Side" YAlign="Center" XAlign="Center" />
</StackLayout>
<StackLayout HorizontalOptions="EndAndExpand" Orientation="Horizontal">
<Picker x:Name="cfsPicker" IsVisible="false" SelectedIndexChanged="cfsOnPickerSelectedIndexChanged" ItemsSource="{Binding Languages}"></Picker>
<local:LabelBodyRendererClass x:Name="cfsLabel" />
<Label Text="{x:Static local:FontAwesome.FAAngleRight}" FontFamily="FontAwesome" TextColor="Gray" XAlign="Center" HorizontalOptions="EndAndExpand" />
</StackLayout>
</StackLayout>
</StackLayout>
答案 0 :(得分:2)
您是否尝试过Grid.GestureRecognizers
....
<Grid>
<Grid.GestureRecognizers>
<TapGestureRecognizer Command="{Binding OpenPickerCommand}" CommandParameter="{x:Reference cfsPicker}" NumberOfTapsRequired="1" />
</Grid.GestureRecognizers>
</Grid>