I am trying to apply the same kind of idea explaind on this question ContextMenu on tap instead of tap and hold to my application using button control.
但是,在执行以下守则时,我有<条码>。
<Button Content="Menu" Margin="0,0,316,699" Grid.Row="1" x:Name="MenuButton" >
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener Tap="GestureListener_Tap" />
</toolkit:GestureService.GestureListener>
<toolkit:ContextMenuService.ContextMenu>
<toolkit:ContextMenu>
<toolkit:MenuItem Header="Add to Favorite" Click="AddFavorite_Click"/>
<toolkit:MenuItem Header="Samples" Click="Samples_Click"/>
<toolkit:MenuItem Header="Send to friends" Click="SendToFriends_Click"/>
<toolkit:MenuItem Header="Links" Click="Links_Click"/>
</toolkit:ContextMenu>
</toolkit:ContextMenuService.ContextMenu>
</Button>
private void GestureListener_Tap(object sender, Microsoft.Phone.Controls.GestureEventArgs e)
{
Button button = sender as Button;
ContextMenu contextMenu = ContextMenuService.GetContextMenu(button);
if (contextMenu.Parent == null)
{
contextMenu.IsOpen = true;
}
}
实际上,仅仅使用边界控制样本代码就给我同样的<条码>。 下面是我例外获得的 st。
at Microsoft.Phone.Controls.ContextMenu.UpdateVisualStates(Boolean useTransitions)
at Microsoft.Phone.Controls.ContextMenu.OnOpened(RoutedEventArgs e)
at Microsoft.Phone.Controls.ContextMenu.<OpenPopup>b__12(Object s, EventArgs e)
at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate,
Object sender, Object args)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)
谁能帮助我如何使守则发挥作用? 我对“Windows Telephone apping”非常新,因此任何帮助都将受到赞赏。