WP8 ContextMenu显示在WrapPanel之上

时间:2014-04-21 10:26:07

标签: c# windows-phone-8

我想在我的应用中设置一个上下文菜单,点击并按住WrapPanel项目,但ContextMenu显示在WrapPanel本身之上。

<Grid x:Name="LayoutRoot" Background="Black">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <!--TitlePanel contains the name of the application and page title-->
    <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
        <TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
        <TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
    </StackPanel>

    <!--ContentPanel - place additional content here-->
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <toolkit:WrapPanel x:Name="wpPanel" Background="Black">
            <toolkit:ContextMenuService.ContextMenu>
                <toolkit:ContextMenu IsZoomEnabled="False" x:Name="cmMenu" >
                    <toolkit:MenuItem x:Name="remove" Header="remove" />
                </toolkit:ContextMenu>
            </toolkit:ContextMenuService.ContextMenu>
        </toolkit:WrapPanel>
    </Grid>
</Grid>

如何让它显示在WrapPanel项目的中间?

注意:如果我删除了TitlePanel,则在WrapPanel项目的中间显示ContextMenu。

1 个答案:

答案 0 :(得分:0)

如果你想在中间设置上边距打开它:

   <toolkit:WrapPanel x:Name="wpPanel" Background="Green">
                    <toolkit:ContextMenuService.ContextMenu>
                        <toolkit:ContextMenu IsZoomEnabled="False" x:Name="cmMenu" Margin="0,50,0,0">
                            <toolkit:MenuItem x:Name="remove" Header="remove"/>
                        </toolkit:ContextMenu>
                    </toolkit:ContextMenuService.ContextMenu>
                </toolkit:WrapPanel>