Xamarin形式列表视图上下文动作不适用于细节
问题描述:
我使用XF列表视图与菜单上下文操作和通过点击选择的视单元。 当我实现TapGestureReconizer时,上下文操作不起作用。Xamarin形式列表视图上下文动作不适用于细节
我的代码是在这里:
<ListView x:Name="PaymentCardsListView"
CachingStrategy="RecycleElement"
ItemsSource="{Binding PaymentCardsList}"
SelectedItem="{Binding SelectedPaymentCard, Mode=TwoWay}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.ContextActions>
<MenuItem Command="{Binding Path=BindingContext.EditCommand, Source={x:Reference PaymentCardsListView}"
CommandParameter="{Binding .}"
Text="Edit"/>
<MenuItem Command="{Binding Path=BindingContext.DeleteCommand, Source={x:Reference PaymentCardsListView}"
CommandParameter="{Binding .}"
IsDestructive="true"
Text="Delete"/>
</ViewCell.ContextActions>
<StackLayout Orientation="Horizontal">
<StackLayout.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Path=BindingContext.DetailCommand, Source={x:Reference PaymentCardsListView}"
CommandParameter="{Binding .}"/>
</StackLayout.GestureRecognizers>
<StackLayout Orientation="Vertical">
<Label Text="{Binding Name}"/>
<Label Text="{Binding Number}"/>
<StackLayout Orientation="Horizontal">
<Label Text="Expiry Date: "/>
<Label Text="{Binding ExpMonth}"/>
<Label Text="/"/>
<Label Text="{Binding ExpYear}"/>
</StackLayout>
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
我需要上下文菜单,stacklayout自来水工作。 我应该如何实施?
它适用于iOS。 这个问题只在Android上。
答
我发现bugzilla上的确认错误。
https://bugzilla.xamarin.com/show_bug.cgi?id=46363
我在想演练。 其中之一,它为android的视图单元格创建自定义渲染器,并覆盖LongPress以显示自定义菜单。
如果你找到你的解决方案,你可以接受你自己的答案。 – testing