This is for Windows Phone 7.5
I am not able to remove menuitems from my contextmenu based on the pivotitem. I have three pivotitems and I need to show the custom items in the context menu.
I am trying to find the right event that can help me capture the current pivot item and based on that I would like to present context menu options.
Update #1:
Xaml Markup:
<controls:PivotItem x:Name="HighPivotItem" Header="high">
<toolkit:ContextMenuService.ContextMenu>
<toolkit:ContextMenu Opened="ContextMenu_Opened"
Closed="ContextMenu_Closed">
<toolkit:MenuItem Header="mark as done" Click="MarkMenuItem_Click"/>
<toolkit:MenuItem Header="edit" Click="EditMenuItem_Click"/>
<toolkit:MenuItem Header="delete" Click="DeleteMenuItem_Click"/>
</toolkit:ContextMenu>
</toolkit:ContextMenuService.ContextMenu>
<Grid>
<TextBlock x:Name="HighTextBlock" Text=""
Visibility="Collapsed" Margin="22,17,0,0"
Style="{StaticResource PhoneTextGroupHeaderStyle}" />
<ListBox x:Name="HighListBox"
ItemTemplate="{StaticResource DataTemplate}"
SelectionChanged="ListBox_SelectionChanged" />
</Grid>
</controls:PivotItem>
Here is the code in my event:
void MarkMenuItem_Click(object sender, RoutedEventArgs e)
{
Task task = (sender as MenuItem).DataContext as Task;
// Move from the task list to the done list
Settings.TaskList.Value.Remove(task);
Settings.DoneList.Value.Add(task);
RefreshLists();
}
You should be designing your context menus per pivot item
The menus can be placed into a datatemplate for a listbox, or onto individual items.
The example above assumes that the page has a DataContext that has a property “Task”