First of all, I know about this topic: How to make context menu work for windows phone?
But this way is SOO complicated... So I have this XAML code:
<StackPanel Name="friendsGrid" Margin="0,0,0,0" Background="Transparent">
<ListBox Name="friendsListBox" FontSize="32" Tap="friendsListBox_Tap">
<toolkit:ContextMenuService.ContextMenu>
<toolkit:ContextMenu Name="MyContextMenu" Opened="MyContextMenu_Opened">
<toolkit:MenuItem Header="action" Click="contextMenuAction_Click"/>
</toolkit:ContextMenu>
</toolkit:ContextMenuService.ContextMenu>
</ListBox>
</StackPanel>
And I'm filling the list like this:
this.friendsListBox.Items.Add(friend.serviceName);
But, of course, when I do longtap, the context menu appears and selects the whole List, not only one item.
Is there some easy way to recognize the item was tapped? Thanks
BTW, I found this method, but contextMenuListItem doesn't recieve anything, it's still null:
ListBoxItem contextMenuListItem = friendsListBox.ItemContainerGenerator.ContainerFromItem((sender as ContextMenu).DataContext) as ListBoxItem;