ContextMenu.Placement 属性

定义

获取或设置 PlacementContextMenu 属性。Gets or sets the Placement property of a ContextMenu.

public:
 property System::Windows::Controls::Primitives::PlacementMode Placement { System::Windows::Controls::Primitives::PlacementMode get(); void set(System::Windows::Controls::Primitives::PlacementMode value); };
[System.ComponentModel.Bindable(true)]
public System.Windows.Controls.Primitives.PlacementMode Placement { get; set; }
member this.Placement : System.Windows.Controls.Primitives.PlacementMode with get, set
Public Property Placement As PlacementMode

属性值

PlacementMode 枚举之一。One of the PlacementMode enumeration. 默认值为 MousePointThe default is MousePoint.

属性

示例

下面的示例演示如何使用Placement属性和放置模式来指定放置ContextMenu位置。The following example shows how to use the Placement property and a placement mode to specify where the ContextMenu is placed.

<ContextMenu Placement="Bottom" PlacementRectangle="30,50,0,0">

注解

ContextMenuService ContextMenu当分配FrameworkElement.ContextMenu给或FrameworkContentElement.ContextMenu属性时, 会在打开时更改此属性的此值。 ContextMenuWhen the ContextMenu is assigned to the FrameworkElement.ContextMenu or FrameworkContentElement.ContextMenu property, the ContextMenuService changes this value of this property when the ContextMenu opens. 如果用户使用鼠标打开ContextMenu , Placement则将设置为MousePointIf the user opens the ContextMenu by using the mouse, Placement is set to MousePoint. 如果用户使用键盘打开ContextMenu , Placement则将设置为CenterIf the user opens the ContextMenu by using the keyboard, Placement is set to Center. 如果要更改ContextMenu的位置, 请在FrameworkElementFrameworkContentElementContextMenuService.Placement设置属性。If you want to change the position of the ContextMenu, set the ContextMenuService.Placement property on the FrameworkElement or FrameworkContentElement.

ContextMenu Placement PlacementRectangle通过设置、、HorizontalOffset、和VerticalOffsetProperty属性, 可以定位。 PlacementTargetYou can position a ContextMenu by setting the PlacementTarget, PlacementRectangle, Placement, HorizontalOffset, and VerticalOffsetProperty properties. 这些属性的行为与对Popup的行为相同。These properties behave the same as they do for a Popup. 有关详细信息,请参阅 Popup 放置行为For more information, see Popup Placement Behavior.

依赖项属性信息Dependency Property Information

标识符字段Identifier field PlacementProperty
元数据属性设置为trueMetadata properties set to true NoneNone

适用于

另请参阅