vb.netwindows-phone-7contextmenutoolstripapplication-bar

WP7 Toolkit: Open ContextMenu from ApplicationBar (contextmenu not displayed)


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


Solution

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