[Beginner question] How to implement a context menu for each item in a list view

I am coding a universal windows 8.1 application and I have very limited experience with context menus I have a list view with items that are added to it as the user adds entries. I want each item in the listView to have the same context menu so I made a flyoutMenu resource

<Page.Resources> <MenuFlyout x:Name="flymenDelete"> <MenuFlyoutItem Text="Delete" Click="MenuFlyoutItem_Click"/> </MenuFlyout> </Page.Resources> 

Then I add the menu to my listView

<ListView x:Name="lstvwHours" FlyoutBase.AttachedFlyout="{StaticResource flymenDelete}" HorizontalAlignment="Left" Height="264" Margin="427,77,0,0" VerticalAlignment="Top" Width="357" RightTapped="lstvwHours_RightTapped"> </ListView> 

and I have my event to handle the right click

private void Button_RightTapped(object sender, RightTappedRoutedEventArgs e) { FlyoutBase.ShowAttachedFlyout((FrameworkElement)sender); } 

The problem with this is it shows the a context menu but only for the actual listView control and not the items inside the list view. How do I have it so this context menu only appears when the listViewItems are rightclicked keeping in mind that these items are not hardcoded.

by mavese via /r/csharp

Leave a Reply