English 中文(简体)
ContextMenu on thetap rather thantap and hold with Button Control
原标题:ContextMenu on tap instead of tap and hold with Button Control

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”非常新,因此任何帮助都将受到赞赏。

问题回答

这里的问题。

这部法典造成了::

private void UpdateVisualStates(bool useTransitions) 
[..]
_outerPanel.Orientation = Orientation.Vertical;

此时此刻,未打电话到OnApplyTemplate (),因此,_outer Pane l 无效。

如果这一问题无效并重整工具包,就可以解决这一问题。

遗憾的是,微软拒绝设置

...... Stefan

我建议两点:

(1) 银灯工具包第7.1条有点,因此,在把环境从除举行活动以外的任何东西中划出时,你会例外。

<Button Content="Menu" Margin="0,0,316,699" Grid.Row="1" x:Name="MenuButton" Hold="MenuButton_Hold"/>

    <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>

C# code is ok as it is just copy it to the hold event

2) 您必须把背景菜单放在纽子的方括号中,再回到7个银灯箱。

<Button Content="Menu" Margin="0,0,316,699" Grid.Row="1" x:Name="MenuButton" Click="MenuButton_Click"/>

    <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>




相关问题
System.Json namespace missing from Windows Phone 7

During a Mix10 presentation, the presenter (Charlie Kindel) said that when writing Silverlight based apps for WP7 you get all of Silverlight 3.0 with some of Silverlight 4.0 mixed in. Why then is ...

Will Windows Phone 7 Support Multitasking third party apps

Obviously it s early days, I do not know whether this is information that is in the public domain or not yet, but... I have trawled through some of this site - http://www.windowsphone7series.com/ but ...

Windows Series Phone 7 "Cloud"

I have been reading up on "Cloud computing" on here and still not getting it. Basically I want to develop for the WP7 http://msdn.microsoft.com/en-us/library/ff402531%28v=VS.92%29.aspx#...

Windows Phone 7 Tab Pages (page cycle)

I know.. I know, it s only a few hours old. But how the hell do you get the little page tabbing/cycle (forgot what the official name is) on the top of the page under the app title. MIX Keynotes made ...

Recording audio from the microphone in Windows Phone 7 Series

I m wondering if anyone has any code samples or links to documentation that demonstrate how to capture audio from the device s microphone on the new Windows Phone Series 7. I ve recently downloaded ...

Resources for Windows Phone 7 development [closed]

Windows Phone 7 has been unveiled and MS have announced all details of the development chain at the Mix10 conference. So this could be a good starting point/collection of online resources as they ...

热门标签