这适用于 Windows Phone 7.5
我无法根据枢轴项从我的上下文菜单中删除菜单项。我有三个枢轴项,我需要在上下文菜单中显示自定义项。
我正在尝试找到可以帮助我捕获当前数据透视项的正确事件,并基于此我想呈现上下文菜单选项。
更新#1:
Xaml 标记:
<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>
这是我的活动中的代码:
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();
}