I'm having a ListBox (binds to an observable collection) with the ListBoxItems design defined in the ItemsPanel StaticResource. The ItemsPanel is defined in the App.xml (like to have my stuff in a central place and the design for the ListBoxItem is used on different pages) Now for every Listbox I need to have a different ContextMenu, and there comes the thing, I don't get working...
In my App.xaml (small demo - didn't want to bloat the topic, here):
<Application.Resources>
<DataTemplate x:Key="ListItemTemplate">
<TextBlock Text="{Binding Title}" />
</DataTemplate>
</Application.Resources>
In my MainPage.xaml I have the Listbox defined.:
<ListBox ItemsSource="{Binding Items}"
ItemTemplate="{StaticResource ListItemTemplate}">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="toolkit:ContextMenuService.ContextMenu">
<Setter.Value>
<toolkit:ContextMenu>
<toolkit:MenuItem Header="Test" />
</toolkit:ContextMenu>
</Setter.Value>
</Setter>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
However, if I long-press a ListBoxItem, nothing happens. I have no errors - nothing - but the Contextmenu just doesn't show up... (neither in the emulator, nor on the device).
If I add a ContextMenu to the LayoutRoot gird or something else, It works like a charm.