ListView ItemSelected and ItemTapped not working with ContextActions

igorkr_10igorkr_10 Member ✭✭✭

Hi all.
I have a problem with ListView. I have a viewcell with custom control that has TapGestureRecognizer and it works well. But when I added Context Action to ViewCell ItemSelected stoped working.
What can I do to solve this problem?
Thanks for helping.

Best Answer


  • FullEnglishFullEnglish GBMember ✭✭


    Did it stop working on Android only?

  • igorkr_10igorkr_10 Member ✭✭✭

    @FullEnglish said:

    Did it stop working on Android only?

    I don't know. It was checked on Android only.

  • FullEnglishFullEnglish GBMember ✭✭

    OK, well we had the issue with Android and deployed a work around. Let me know if you need further help!

  • anveanve DEMember ✭✭✭

    @FullEnglish: Can you show/explain the workaround?

  • RylaRyla Member ✭✭

    That's how I solved it.
    void ListViewSelected(object sender, Xamarin.Forms.SelectedItemChangedEventArgs e) { if (e.SelectedItem == null) return; ((ListView)sender).SelectedItem = null; var selectedRow = (StudentList)e.SelectedItem; }

    Or Command(try this way)

    Binding Content Page
    <ContentPage.BindingContext> <View:StudentModel> </View:StudentModel> </ContentPage.BindingContext>

    MVVM =
    public Command AddCommand
    return new Command((student) =>


    Select =var button = sender as Button;
    var student = button?.BindingContext as StudentList;
    var vm = BindingContext as StudentModel;`

    Student Class
    Model =
    ` public class StudentList

            public string Name { get; set; }
            public string Seat { get; set; }
            public string SafetyBelt { get; set; }

    if you cannot solve the problem, write me.

  • igorkr_10igorkr_10 Member ✭✭✭

    Thanks for response. I will check your solution later.

  • LeonardKongLeonardKong USMember ✭✭

    I have a similar problem on the iOS platform, but will provide more detail.




    When the listView is displayed, the behavior is as expected, tapping on item correctly handles the itemTapped event.

    My ViewCell has the following ContextActions:


    The behavior is as expected. If the users swipes slowly on an item in the listview, the context menus appear. Tapping on one of the context menu items correctly handles the event.

    HOWEVER, I am finding that the mere act of swiping slow to view the context actions DISABLES the ItemTapped event handler. If I do not initiate a swipe action the ItemTapped event handler behaves as expected, but once I swipe to look at the context actions the ItemTapped event handler no longer behaves correctly. I will note that the Item tapped event handler for other items in the list still continue to work.

    Looking at this thread, it is not clear how the "accepted answer" above solves the problem, since the tap is not even recognized. If I remove the behavior and simply attempt to capture the ItemTapped event in code behind, I get the same result, it does not respond.

  • LeonardKongLeonardKong USMember ✭✭

    Sorry, Let me try that again, parts of the code I posted appears to be missing:

    <ListView ItemsSource="{Binding Source}" x:Name="itemList" IsGroupingEnabled="true" HasUnevenRows="true"> <ListView.ItemTemplate> <DataTemplate> <viewCells:FlightsViewCell/> </DataTemplate> </ListView.ItemTemplate> <ListView.Behaviors> <behaviors:EventToCommandBehavior EventName="ItemTapped" Command="{Binding ListItemTappedCommand}" CommandParameter="{Binding .}"/> </ListView.Behaviors> </ListView>


    <ViewCell.ContextActions> <MenuItem Text="Accept Flight: Yes" IsDestructive="False" Clicked="OnAccept" /> <MenuItem Text="Accept Flight: No" IsDestructive="True" Clicked="OnReject" /> </ViewCell.ContextActions>

  • TaylorDTaylorD USMember ✭✭✭

    @LeonardKong There is an issue for this already in GitHub at has been merged into the Xamarin.Forms code base. Not sure which XF version it will be released in though.

    Issue Link
    Pull Request Link

  • LeonardKongLeonardKong USMember ✭✭

    Thanks for the info!

  • ShawnCastrianniShawnCastrianni USBeta ✭✭✭

    This still exists in XF 4.3.0

  • ShawnCastrianniShawnCastrianni USBeta ✭✭✭

    My mistake, the bug of Tapped not working AFTER revealing the ContextActions seems to be fixed. But now something worse is broken. Just having ContextActions at all, blocks input to the Tapped event except for at the very bottom of the cell where the divider is.

Sign In or Register to comment.