FrameworkContentElement.ContextMenu 属性

定义

获取或设置每当通过用户界面 (UI)user interface (UI) 从此元素中请求上下文菜单时应该显示的上下文菜单元素。Gets or sets the context menu element that should appear whenever the context menu is requested via 用户界面 (UI)user interface (UI) from within this element.

public:
 property System::Windows::Controls::ContextMenu ^ ContextMenu { System::Windows::Controls::ContextMenu ^ get(); void set(System::Windows::Controls::ContextMenu ^ value); };
public System.Windows.Controls.ContextMenu ContextMenu { get; set; }
member this.ContextMenu : System.Windows.Controls.ContextMenu with get, set
Public Property ContextMenu As ContextMenu

属性值

此元素使用的上下文菜单。The context menu that this element uses.

示例

下面的示例将 ContextMenu 放置在 Paragraph上。The following example places a ContextMenu on a Paragraph.

<Paragraph>Lorem ipsum etc.
  <Paragraph.ContextMenu>
    <ContextMenu Name="cm">
      <MenuItem Header="Edit"/>
      <MenuItem Header="Print"/>
    </ContextMenu>
  </Paragraph.ContextMenu>
</Paragraph>

注解

依赖项属性信息Dependency Property Information

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

适用于

另请参阅