ContextMenuService.PlacementRectangle Propriedade anexada

Definição

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

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

Exemplos

O exemplo a seguir atribui o mesmo ContextMenu a dois botões e define as HasDropShadowpropriedades , Placement, PlacementRectangleHorizontalOffsete VerticalOffset , para definir as ContextMenu posições 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>

Comentários

Você pode posicionar um ContextMenu definindo as PlacementTargetpropriedades, , PlacementRectanglePlacementHorizontalOffsete ,VerticalOffsetProperty Essas propriedades se comportam da mesma forma que se comportam para um Popup. Para obter mais informações, consulte Comportamento de Posicionamento de Pop-up.

Informações da propriedade Dependency

Item Value
Campo identificador PlacementRectangleProperty
Propriedades de metadados definidas como true None

Aplica-se a

Confira também