Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin forms listview context action doesn't work with details

I use XF listview with menu context action and viewcell selected by tap. The context actions don't work when I implemented TapGestureReconizer.

My code is here:

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

I need to work with context menu and stacklayout tap. How should I implement this?

It works on iOS. The issue is only on Android.

like image 819
Atlantis Avatar asked Jan 25 '26 05:01

Atlantis


1 Answers

I found confirmed bug on bugzilla.

https://bugzilla.xamarin.com/show_bug.cgi?id=46363

I'm thinking about walkthrough. One of them it create custom renderer for view cell for android and override LongPress for display custom menu.

like image 197
Atlantis Avatar answered Jan 29 '26 01:01

Atlantis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!