In This Article

BarMenuItem Class

Represents a menu item control, for use within a menu.

[TemplatePart(Name = "PART_Popup", Type = typeof(Popup))]
[TemplatePart(Name = "PART_PopupContentHost", Type = typeof(ResizablePopupContentHost))]
public class BarMenuItem : MenuItem
Inheritance:
object Visual UIElement FrameworkElement Control ItemsControl HeaderedItemsControl MenuItem object
Derived:
BarSplitMenuItem

Constructors

BarMenuItem()

Initializes a new instance of the BarMenuItem class.

public BarMenuItem()

BarMenuItem(string)

Initializes a new instance of the BarMenuItem class with the specified label.

public BarMenuItem(string label)
Parameter Type Description
label string

The text label to display.

Properties

CanCloneToRibbonQuickAccessToolBar

Gets or sets whether the control can be cloned to the ribbon quick-access toolbar.

public bool CanCloneToRibbonQuickAccessToolBar { get; set; }

Property Value

bool:

true if the control can be cloned to the ribbon quick-access toolbar; otherwise, false. The default value is true.

CanEffectivelyExecute

Gets whether the control can effectively execute the Command.

public bool CanEffectivelyExecute { get; protected set; }

Property Value

bool:

true if the control can effectively execute the Command; otherwise, false.

CanEffectivelyOpenSubMenu

Gets whether the control can effectively open its sub-menu.

public bool CanEffectivelyOpenSubMenu { get; protected set; }

Property Value

bool:

true if the control can effectively open its sub-menu; otherwise, false.

Description

Gets or sets the extended description of the menu item, displayed in large menu items.

[Localizability(LocalizationCategory.Text)]
public string Description { get; set; }

Property Value

string:

The extended description of the menu item.

See Also

IsEnabledCore

Gets a value that indicates whether the IsEnabled property is true for the current menu item.

protected override bool IsEnabledCore { get; }

Property Value

bool:

true if the MenuItem can be selected; otherwise, false.

IsInputGestureTextVisible

Gets or sets whether the input gesture text is allowed to be visible in the user interface.

public bool IsInputGestureTextVisible { get; set; }

Property Value

bool:

true if the input gesture text is allowed to be visible in the user interface; otherwise, false. The default value is true.

Key

Gets or sets a string that uniquely identifies the control.

[Localizability(LocalizationCategory.NeverLocalize)]
public string Key { get; set; }

Property Value

string:

A string that uniquely identifies the control.

KeyTipText

Gets or sets the key tip text used to access the control.

[Localizability(LocalizationCategory.Label)]
public string KeyTipText { get; set; }

Property Value

string:

The key tip text used to access the control.

Label

Gets or sets the text label to display.

[Localizability(LocalizationCategory.Label)]
public string Label { get; set; }

Property Value

string:

The text label to display.

LargeImageSource

Gets or sets the ImageSource for a large image, generally 32x32 size.

public ImageSource LargeImageSource { get; set; }

Property Value

ImageSource:

The ImageSource for a large image.

PopupOpeningCommand

Gets or sets the ICommand that executes before the menu item's popup is opened, allowing its items to be customized in MVVM scenarios.

public ICommand PopupOpeningCommand { get; set; }

Property Value

ICommand:

The ICommand that executes before the menu item's popup is opened, allowing its items to be customized in MVVM scenarios.

ScreenTipFooter

Gets or sets the screen tip footer content.

public object ScreenTipFooter { get; set; }

Property Value

object:

The screen tip footer content.

ScreenTipHeader

Gets or sets the screen tip header content.

public object ScreenTipHeader { get; set; }

Property Value

object:

The screen tip header content.

SmallImageSource

Gets or sets the ImageSource for a small image, generally 16x16 size.

public ImageSource SmallImageSource { get; set; }

Property Value

ImageSource:

The ImageSource for a small image.

Title

Gets or sets the string title, which can override the Label when displayed in screen tips and customization UI.

[Localizability(LocalizationCategory.Title)]
public string Title { get; set; }

Property Value

string:

The string title.

UseLargeSize

Gets or sets whether to use a large size.

public bool UseLargeSize { get; set; }

Property Value

bool:

true if a large size should be used; otherwise, false. The default value is false.

See Also

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 a specified item.

protected override DependencyObject GetContainerForItemOverride()

Returns

DependencyObject:

The element used to display a specified item.

IsItemItsOwnContainerOverride(object)

Determines if the specified item is (or is eligible to be) its own ItemContainer.

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

Specified item.

Returns

bool:

true if the item is its own ItemContainer; otherwise, false.

OnApplyTemplate()

Called when the template's tree is generated.

public override void OnApplyTemplate()

OnClick()

Called when a MenuItem is clicked and raises a Click event.

protected override void OnClick()

OnCreateAutomationPeer()

Provides an appropriate MenuItemAutomationPeer implementation for this control, as part of the WPF automation infrastructure.

protected override AutomationPeer OnCreateAutomationPeer()

Returns

AutomationPeer:

A MenuItemAutomationPeer for this MenuItem.

OnGotKeyboardFocus(KeyboardFocusChangedEventArgs)

Announces that the keyboard is focused on this element.

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

The event data for the GotFocus event.

OnInitialized(EventArgs)

Called when the IsInitialized property is set to true and raises an Initialized event.

protected override void OnInitialized(EventArgs e)
Parameter Type Description
e EventArgs

The event data for the Initialized event.

OnIsKeyboardFocusWithinChanged(DependencyPropertyChangedEventArgs)

Called when the focus is no longer on or within a MenuItem.

protected override void OnIsKeyboardFocusWithinChanged(DependencyPropertyChangedEventArgs e)
Parameter Type Description
e DependencyPropertyChangedEventArgs

The event data for the IsKeyboardFocusWithinChanged event.

OnItemsChanged(NotifyCollectionChangedEventArgs)

Called when the Items property changes.

protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e)
Parameter Type Description
e NotifyCollectionChangedEventArgs

The event data for the ItemsChanged event.

OnKeyDown(KeyEventArgs)

Responds to the KeyDown event.

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

The event data for the KeyDown event.

OnKeyTipInvoked(KeyTipInvokedEventArgs)

Occurs when the control's key tip is invoked.

protected virtual void OnKeyTipInvoked(KeyTipInvokedEventArgs e)
Parameter Type Description
e KeyTipInvokedEventArgs

The KeyTipInvokedEventArgs containing data related to this event.

OnKeyTipOpening(KeyTipOpeningEventArgs)

Occurs when the control's key tip is opening.

protected virtual void OnKeyTipOpening(KeyTipOpeningEventArgs e)
Parameter Type Description
e KeyTipOpeningEventArgs

The KeyTipOpeningEventArgs containing data related to this event.

OnKeyUp(KeyEventArgs)

Invoked when an unhandled System.Windows.Input.Keyboard.KeyUp 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 OnKeyUp(KeyEventArgs e)
Parameter Type Description
e KeyEventArgs

The KeyEventArgs that contains the event data.

OnLostKeyboardFocus(KeyboardFocusChangedEventArgs)

Invoked when an unhandled System.Windows.Input.Keyboard.LostKeyboardFocus 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 OnLostKeyboardFocus(KeyboardFocusChangedEventArgs e)
Parameter Type Description
e KeyboardFocusChangedEventArgs

The KeyboardFocusChangedEventArgs that contains event data.

OnMouseEnter(MouseEventArgs)

Called whenever the mouse enters a MenuItem.

protected override void OnMouseEnter(MouseEventArgs e)
Parameter Type Description
e MouseEventArgs

The event data for the System.Windows.Input.Mouse.MouseEnter event.

OnMouseLeave(MouseEventArgs)

Called whenever the mouse leaves a MenuItem.

protected override void OnMouseLeave(MouseEventArgs e)
Parameter Type Description
e MouseEventArgs

The event data for the System.Windows.Input.Mouse.MouseLeave event.

OnMouseLeftButtonDown(MouseButtonEventArgs)

Called when the left mouse button is pressed.

protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
Parameter Type Description
e MouseButtonEventArgs

The event data for the MouseLeftButtonDown event.

OnMouseRightButtonDown(MouseButtonEventArgs)

Called when the right mouse button is pressed.

protected override void OnMouseRightButtonDown(MouseButtonEventArgs e)
Parameter Type Description
e MouseButtonEventArgs

The event data for the MouseRightButtonDown event.

OnMouseRightButtonUp(MouseButtonEventArgs)

Called when the right mouse button is released.

protected override void OnMouseRightButtonUp(MouseButtonEventArgs e)
Parameter Type Description
e MouseButtonEventArgs

The event data for the MouseRightButtonUp event.

OnPropertyChanged(DependencyPropertyChangedEventArgs)

Invoked whenever the effective value of any dependency property on this FrameworkElement has been updated. The specific dependency property that changed is reported in the arguments parameter. Overrides System.Windows.DependencyObject.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs).

protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
Parameter Type Description
e DependencyPropertyChangedEventArgs

The event data that describes the property that changed, as well as old and new values.

OnSubmenuOpening(CancelRoutedEventArgs)

Occurs before the IsSubmenuOpen property changes to true.

protected virtual void OnSubmenuOpening(CancelRoutedEventArgs e)
Parameter Type Description
e CancelRoutedEventArgs

The CancelRoutedEventArgs that contains the event data.

Remarks

This method has no default implementation. Because an intermediate class in the inheritance might implement this method, we recommend that you call the base implementation in your implementation.

OnToolTipOpening(ToolTipEventArgs)

Invoked whenever the ToolTipOpening routed event reaches this class in its route. Implement this method to add class handling for this event.

protected override void OnToolTipOpening(ToolTipEventArgs e)
Parameter Type Description
e ToolTipEventArgs

Provides data about the event.

OnVisualParentChanged(DependencyObject)

Called when the parent of the visual MenuItem changes.

protected override void OnVisualParentChanged(DependencyObject oldParent)
Parameter Type Description
oldParent DependencyObject

Old value of the parent of the visual, or null if the visual did not have a parent.

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.

ToString()

Returns the string representation of this object.

public override string ToString()

Returns

string:

The string representation of this object.

UpdateEnabledProperties()

protected virtual void UpdateEnabledProperties()

Events

SubmenuOpening

Occurs before the IsSubmenuOpen property changes to true.

public event EventHandler<CancelRoutedEventArgs> SubmenuOpening

Event Type

EventHandler<CancelRoutedEventArgs>

Fields

CanCloneToRibbonQuickAccessToolBarProperty

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

public static readonly DependencyProperty CanCloneToRibbonQuickAccessToolBarProperty

CanEffectivelyExecuteProperty

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

public static readonly DependencyProperty CanEffectivelyExecuteProperty

CanEffectivelyOpenSubMenuProperty

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

public static readonly DependencyProperty CanEffectivelyOpenSubMenuProperty

DescriptionProperty

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

public static readonly DependencyProperty DescriptionProperty

IsInputGestureTextVisibleProperty

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

public static readonly DependencyProperty IsInputGestureTextVisibleProperty

KeyProperty

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

public static readonly DependencyProperty KeyProperty

KeyTipTextProperty

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

public static readonly DependencyProperty KeyTipTextProperty

LabelProperty

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

public static readonly DependencyProperty LabelProperty

LargeImageSourceProperty

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

public static readonly DependencyProperty LargeImageSourceProperty

PopupOpeningCommandProperty

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

public static readonly DependencyProperty PopupOpeningCommandProperty

ScreenTipFooterProperty

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

public static readonly DependencyProperty ScreenTipFooterProperty

ScreenTipHeaderProperty

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

public static readonly DependencyProperty ScreenTipHeaderProperty

SmallImageSourceProperty

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

public static readonly DependencyProperty SmallImageSourceProperty

SubmenuOpeningEvent

Identifies the SubmenuOpening routed event. This field is read-only.

public static readonly RoutedEvent SubmenuOpeningEvent

TitleProperty

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

public static readonly DependencyProperty TitleProperty

UseLargeSizeProperty

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

public static readonly DependencyProperty UseLargeSizeProperty