ContextMenuService.Placement ContextMenuService.Placement ContextMenuService.Placement Attached Property

Definición

Obtiene o establece un valor que especifica la posición de ContextMenu en relación con PlacementTarget o PlacementRectangle.Gets or sets a value that specifies the placement of the ContextMenu relative to the PlacementTarget or PlacementRectangle.

see GetPlacement, and SetPlacement
see GetPlacement, and SetPlacement
see GetPlacement, and SetPlacement

Ejemplos

En el ejemplo siguiente se asigna el mismo ContextMenu a dos botones y se establece la HasDropShadow, Placement, PlacementRectangle, HorizontalOffset, y VerticalOffset propiedades para establecer el ContextMenu en posiciones diferentes para cada botón.The following example assigns the same ContextMenu to two buttons and sets the HasDropShadow, Placement, PlacementRectangle, HorizontalOffset, and VerticalOffset properties to set the ContextMenu to different positions for each button.

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

Comentarios

Puede colocar un ContextMenu estableciendo el PlacementTarget, PlacementRectangle, Placement, HorizontalOffset, y VerticalOffsetProperty propiedades.You can position a ContextMenu by setting the PlacementTarget, PlacementRectangle, Placement, HorizontalOffset, and VerticalOffsetProperty properties. Estas propiedades comportan igual que un Popup.These properties behave the same as they do for a Popup. Para más información, consulte Posición de un control Popup.For more information, see Popup Placement Behavior.

Información sobre propiedades de dependenciaDependency Property Information

Campo de identificadorIdentifier field PlacementProperty
Establecen las propiedades de metadatos en trueMetadata properties set to true NoneNone

Se aplica a

Consulte también: