ContextMenuService.PlacementRectangle Propriedade Anexada

Definição

Obtém ou define a área relativa à qual o menu de contexto está posicionado quando abre.

see GetPlacementRectangle, and SetPlacementRectangle
see GetPlacementRectangle, and SetPlacementRectangle
see GetPlacementRectangle, and SetPlacementRectangle

Exemplos

O exemplo seguinte atribui o mesmo ContextMenu a dois botões e define as HasDropShadowpropriedades , Placement, PlacementRectangle, HorizontalOffset, e VerticalOffset para colocar os ContextMenu em posições diferentes para cada botão.

<StackPanel>
  <StackPanel.Resources>
    <ContextMenu x:Key="myContextMenu">
      <MenuItem Header="Item"/>
    </ContextMenu>
  </StackPanel.Resources>

  <!--Both buttons use the same ContextMenu but use the
    properties on ContextMenuService to position them
    differently.-->
  <Button ContextMenu="{StaticResource myContextMenu}" 
          ContextMenuService.HasDropShadow="False" 
          ContextMenuService.Placement="Relative"
          ContextMenuService.HorizontalOffset="50"
          ContextMenuService.VerticalOffset="-10">
    button 1
  </Button>

  <Button ContextMenu="{StaticResource myContextMenu}" 
          ContextMenuService.HasDropShadow="True"
          ContextMenuService.Placement="Right"
          ContextMenuService.PlacementRectangle="0,0,30,30">
    button 2
  </Button>
</StackPanel>

Observações

Pode posicionar a ContextMenu definindo as PlacementTarget, PlacementRectangle, Placement, HorizontalOffset, e VerticalOffsetProperty propriedades. Estas propriedades comportam-se da mesma forma que para um Popup. Para mais informações, consulte Comportamento de Colocação de Popups.

Informação de Propriedade de Dependência

Iteme Value
Campo identificador PlacementRectangleProperty
Propriedades dos metadados definidas como true None

Aplica-se a

Ver também