I tried to open the ContextMenu from the applicationbar using the "ContextMenu.IsOpen()" method which will run on the event "ApplicationBarIconButton_Click". On the first button click, you see there's s.th. happening/opening. But the ContextMenu is not display correctly. It seems invisible, only the top border is displayed. On second button click everything's fine. I am using the current version of WP7 Toolkit.

XAML

...
            <Grid x:Name="ContentPanel" Margin="12,-16,12,0">
                <ScrollViewer>
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="Loaded">
                            <ec:GoToStateAction StateName="VisualState"/>
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                    <toolkit:ContextMenuService.ContextMenu>
                        <toolkit:ContextMenu IsZoomEnabled="True" x:Name="ctxContextMenu" Margin="0" CacheMode="BitmapCache" BorderThickness="2"/>
                    </toolkit:ContextMenuService.ContextMenu>
                    <StackPanel Orientation="Vertical">
                        ...

XAML of AppBar:

<phone:PhoneApplicationPage.ApplicationBar>
    <shell:ApplicationBar IsVisible="True" IsMenuEnabled="False">
        <shell:ApplicationBarIconButton Click="btnExternVisit_Click" IconUri="/Images/visit.png" Text="Externe Links"/>
    </shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>

VB.NET:

Dim ctxItem As New MenuItem() With {.Header = "Text"}
                AddHandler ctxItem.Tap, Sub()
                                            Dim showWeb As New WebBrowserTask()
                                            showWeb.Uri = New Uri("uri")
                                            showWeb.Show()
                                        End Sub
                ctxContextMenu.Items.Add(ctxItem)

Here is what it looks like:

ContextMenu is not displayed correctly

Thanks in advance

有帮助吗?

解决方案 2

It seemed to be a bug in Windows Phone.

After GDR2/Amber update of Windows Phone 8 everything's fine now.

I will place the button outside the menubar to get it to work for older versions.

其他提示

You have nothing in your context menu. You need MenuItem instances inside it.

<toolkit:ContextMenuService.ContextMenu>
    <toolkit:ContextMenu>
        <toolkit:MenuItem Header="A"/>
        <toolkit:MenuItem Header="B"/>
        <toolkit:MenuItem Header="C"/>
    </toolkit:ContextMenu>
</toolkit:ContextMenuService.ContextMenu>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top