2014-04-21 50 views
1

我想在我的应用程序中显示一个上下文菜单,当点击并按住WrapPanel项目时,但ContextMenu显示在WrapPanel本身的顶部。WP8 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,ContextMenu显示在WrapPanel项目的中间。

回答

0

如果你想在middile设置上边距像这样打开它:

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

对不起,我的意思是文本菜单应该出现在WrapPanel项目的中间。 – jerwin

+0

根据需要调整页边中间的上下文菜单 –

+0

您可以设置VirticalAlignment =“Center”,但这不符合您的要求 –