ContextMenuService.PlacementRectangle Właściwość dołączona

Definicja

Pobiera lub ustawia obszar, względem którego menu kontekstowe jest ustawiane po otwarciu.

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

Przykłady

Poniższy przykład przypisuje te same ContextMenu przyciski do dwóch przycisków i ustawia HasDropShadowwłaściwości , Placement, PlacementRectangle, HorizontalOffseti VerticalOffset w celu ustawienia ContextMenu wartości na różne pozycje dla każdego przycisku.

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

Uwagi

Element można ustawićContextMenu, ustawiając właściwości , , PlacementPlacementRectangle, HorizontalOffseti VerticalOffsetProperty .PlacementTarget Te właściwości zachowują się tak samo jak w przypadku elementu Popup. Aby uzyskać więcej informacji, zobacz Zachowanie umieszczania w oknie podręcznym.

Informacje dotyczące właściwości zależności

Pole identyfikatora PlacementRectangleProperty
Właściwości metadanych ustawione na true Brak

Dotyczy

Zobacz też