Język

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

Definicja

Pobiera lub ustawia wartość, która określa położenie ContextMenu elementu względem wartości PlacementTarget lub PlacementRectangle.

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

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 PlacementTargetwłaściwości , PlacementRectangle, Placement, HorizontalOffseti VerticalOffsetProperty . Te właściwości zachowują się tak samo jak w przypadku elementu Popup. Aby uzyskać więcej informacji, zobacz Zachowanie rozmieszczania okienka podręcznego.

Informacje o właściwości zależności

Przedmiot Wartość
Pole identyfikatora PlacementProperty
Właściwości metadanych ustawione na true Żadne

Dotyczy

Zobacz też