0

How do I know if ContextActions appears on my Android device?

I would like to receive events that come from a Long Click item in a ListView.

David Conlisk
  • 3,387
  • 4
  • 33
  • 39

1 Answers1

0

Use the Clicked Event:

<ViewCell.ContextActions>
    <MenuItem
        Icon="chat.png"
        CommandParameter="{Binding .}"
        Text="Chat"
        Clicked="Handle_Chat_Tapped">
    </MenuItem>
</ViewCell.ContextActions>

Handle the event in code behind like this:

void Handle_Chat_Tapped(object sender, System.EventArgs e)
{
    var menuItem = sender as MenuItem;
    // whatever you want to do here
}

Read more about the topic in the Xamarin documentation: https://developer.xamarin.com/guides/xamarin-forms/user-interface/listview/interactivity/#Context_Actions

Dennis Schröer
  • 2,392
  • 16
  • 46
  • Thank you for your time. Dannis :) Thank you for your help. But what I want is that if the ContextActions of the ListViewItem is selected, I want the ContextActions of the other ListViewItem not to be active. So I would like to disable clicking on the ListView anymore when ContextActions is selected. – user3630962 Jan 18 '18 at 07:39
  • Got it. You should edit your question because this is now a completely different question from the original one I answered, so it's easier for you to receive an answer – Dennis Schröer Jan 18 '18 at 08:22
  • Ok, I'm make new question – user3630962 Jan 18 '18 at 08:30