ContextMenuService.PlacementRectangle Ansluten egenskap

Definition

Hämtar eller anger området i förhållande till vilket snabbmenyn placeras när den öppnas.

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

Exempel

I följande exempel tilldelas samma ContextMenu till två knappar och egenskaperna HasDropShadow, Placement, PlacementRectangle, HorizontalOffsetoch VerticalOffset anges ContextMenu till olika positioner för varje knapp.

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

Kommentarer

Du kan placera en ContextMenu genom att PlacementTargetange egenskaperna , PlacementRectangle, Placement, HorizontalOffsetoch VerticalOffsetProperty . Dessa egenskaper fungerar på samma sätt som för en Popup. Mer information finns i Beteende för placering av popup-fönster.

Information om beroendeegenskap

Objekt Value
Identifierarfält PlacementRectangleProperty
Metadataegenskaper inställda på true Ingen

Gäller för

Se även