2014-04-21 48 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」,但這不符合您的要求 –