In This Article

BarContextMenu Class

Represents a context menu that can host any bar control.

[TemplatePart(Name = "PART_MiniToolBarPresenter", Type = typeof(ContentPresenter))]
public class BarContextMenu : ContextMenu
Inheritance:
object Visual UIElement FrameworkElement Control ItemsControl MenuBase ContextMenu object

Constructors

BarContextMenu()

Initializes a new instance of the BarContextMenu class.

public BarContextMenu()

Properties

IsMiniToolBarAbove

Gets whether the mini-toolbar is above the menu.

public bool IsMiniToolBarAbove { get; }

Property Value

bool:

true if the mini-toolbar is above the menu; otherwise, false.

MiniToolBar

Gets the MiniToolBar in use.

public MiniToolBar MiniToolBar { get; }

Property Value

MiniToolBar:

The MiniToolBar in use.

MiniToolBarContent

Gets or sets the mini-toolbar.

public object MiniToolBarContent { get; set; }

Property Value

object:

The mini-toolbar, which can either be a mini-toolbar view model that uses ItemContainerTemplateSelector for its UI, or a MiniToolBar control instance.

MiniToolBarStyle

Gets or sets the Style that targets MiniToolBar and is applied to the instance generated by the MiniToolBarContent property.

public Style MiniToolBarStyle { get; set; }

Property Value

Style:

The Style that targets MiniToolBar.

Methods

ClearContainerForItemOverride(DependencyObject, object)

When overridden in a derived class, undoes the effects of the PrepareContainerForItemOverride(DependencyObject, object) method.

protected override void ClearContainerForItemOverride(DependencyObject element, object item)
Parameter Type Description
element DependencyObject

The container element.

item object

The item.

GetContainerForItemOverride()

Creates or identifies the element used to display the specified item.

protected override DependencyObject GetContainerForItemOverride()

Returns

DependencyObject:

The element used to display the specified item.

IsItemItsOwnContainerOverride(object)

Determines whether the specified item is, or is eligible to be, its own item container.

protected override bool IsItemItsOwnContainerOverride(object item)
Parameter Type Description
item object

The item to check whether it is an item container.

Returns

bool:

true if the item is a MenuItem or a Separator; otherwise, false.

OnApplyTemplate()

When overridden in a derived class, is invoked whenever application code or internal processes call ApplyTemplate().

public override void OnApplyTemplate()

OnContextMenuOpening(ContextMenuEventArgs)

Invoked whenever an unhandled ContextMenuOpening routed event reaches this class in its route. Implement this method to add class handling for this event.

protected override void OnContextMenuOpening(ContextMenuEventArgs e)
Parameter Type Description
e ContextMenuEventArgs

The RoutedEventArgs that contains the event data.

OnCreateAutomationPeer()

Creates and returns a ContextMenuAutomationPeer object for this ContextMenu.

protected override AutomationPeer OnCreateAutomationPeer()

Returns

AutomationPeer:

A ContextMenuAutomationPeer object for this ContextMenu.

OnKeyDown(KeyEventArgs)

Called when a KeyDown event is raised by an object inside the ContextMenu.

protected override void OnKeyDown(KeyEventArgs e)
Parameter Type Description
e KeyEventArgs

The event data for the KeyDown event.

OnOpened(RoutedEventArgs)

Called when the Opened event occurs.

protected override void OnOpened(RoutedEventArgs e)
Parameter Type Description
e RoutedEventArgs

The event data for the Opened event.

OnPreviewGotKeyboardFocus(KeyboardFocusChangedEventArgs)

Invoked when an unhandled System.Windows.Input.Keyboard.PreviewGotKeyboardFocus attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.

protected override void OnPreviewGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
Parameter Type Description
e KeyboardFocusChangedEventArgs

The KeyboardFocusChangedEventArgs that contains the event data.

PrepareContainerForItemOverride(DependencyObject, object)

Prepares the specified element to display the specified item.

protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
Parameter Type Description
element DependencyObject

Element used to display the specified item.

item object

Specified item.

Fields

IsMiniToolBarAboveProperty

Identifies the IsMiniToolBarAbove dependency property. This field is read-only.

public static readonly DependencyProperty IsMiniToolBarAboveProperty

MiniToolBarContentProperty

Identifies the MiniToolBarContent dependency property. This field is read-only.

public static readonly DependencyProperty MiniToolBarContentProperty

MiniToolBarProperty

Identifies the MiniToolBar dependency property. This field is read-only.

public static readonly DependencyProperty MiniToolBarProperty

MiniToolBarStyleProperty

Identifies the MiniToolBarStyle dependency property. This field is read-only.

public static readonly DependencyProperty MiniToolBarStyleProperty