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 an instance of the class.
public BarMenuItem()
BarMenuItem(string?)
Initializes an instance of the class with the specified label.
public BarMenuItem(string? label)
| Parameter | Type | Description |
|---|---|---|
| label | string | The text label to display. |
Properties
CanCloneToRibbonQuickAccessToolBar
Indicates whether the control can be cloned to the ribbon quick-access toolbar.
public bool CanCloneToRibbonQuickAccessToolBar { get; set; }
Property Value
- bool:
trueif the control can be cloned to the ribbon quick-access toolbar; otherwise,false. The default value istrue.
CanEffectivelyExecute
Indicates whether the control can effectively execute the Command.
public bool CanEffectivelyExecute { get; protected set; }
Property Value
CanEffectivelyOpenSubMenu
Indicates whether the control can effectively open its sub-menu.
public bool CanEffectivelyOpenSubMenu { get; protected set; }
Property Value
- bool:
trueif the control can effectively open its sub-menu; otherwise,false.
CanSelectOnPointerOver
Indicates whether the control can focus the menu item on pointer over.
public bool CanSelectOnPointerOver { get; set; }
Property Value
- bool:
trueif the control can focus the menu item on pointer over; otherwise,false.
Description
The extended description of the menu item, displayed in large menu items.
[Localizability(LocalizationCategory.Text)]
public string? Description { get; set; }
Property Value
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
IsInputGestureTextVisible
Indicates whether the input gesture text is allowed to be visible in the user interface.
public bool IsInputGestureTextVisible { get; set; }
Property Value
- bool:
trueif the input gesture text is allowed to be visible in the user interface; otherwise,false. The default value istrue.
Key
A string that uniquely identifies the control.
[Localizability(LocalizationCategory.NeverLocalize)]
public string? Key { get; set; }
Property Value
KeyTipText
The key tip text used to access the control.
[Localizability(LocalizationCategory.Label)]
public string? KeyTipText { get; set; }
Property Value
Label
The text label to display.
[Localizability(LocalizationCategory.Label)]
public string? Label { get; set; }
Property Value
LargeImageSource
The ImageSource for a large image, generally 32x32 size.
PopupClosedCommand
The ICommand that executes after the menu item's popup is closed, allowing its items to be customized in MVVM scenarios.
PopupOpeningCommand
The ICommand that executes before the menu item's popup is opened, allowing its items to be customized in MVVM scenarios.
ScreenTipFooter
The screen tip footer content.
ScreenTipHeader
The screen tip header content.
SmallImageSource
The ImageSource for a small image, generally 16x16 size.
Title
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
UseLargeSize
Indicates whether to use a large size.
public bool UseLargeSize { get; set; }
Property Value
- bool:
trueif a large size should be used; otherwise,false. The default value isfalse.
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:
trueif the item is its ownItemContainer; otherwise,false.
OnApplyTemplate()
Called when the template's tree is generated.
public override void OnApplyTemplate()
OnClick()
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 event data. |
OnKeyTipOpening(KeyTipOpeningEventArgs)
Occurs when the control's key tip is opening.
protected virtual void OnKeyTipOpening(KeyTipOpeningEventArgs e)
| Parameter | Type | Description |
|---|---|---|
| e | KeyTipOpeningEventArgs | The event data. |
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 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.
UpdateEnabledProperties()
Updates the CanEffectivelyExecute and CanEffectivelyOpenSubMenu properties.
protected virtual void UpdateEnabledProperties()
Events
SubmenuOpening
Occurs before the IsSubmenuOpen property changes to true.
public event EventHandler<CancelRoutedEventArgs> SubmenuOpening
Event Type
Fields
CanCloneToRibbonQuickAccessToolBarProperty
Defines the CanCloneToRibbonQuickAccessToolBar property.
public static readonly DependencyProperty CanCloneToRibbonQuickAccessToolBarProperty
CanEffectivelyExecuteProperty
Defines the CanEffectivelyExecute property.
public static readonly DependencyProperty CanEffectivelyExecuteProperty
CanEffectivelyOpenSubMenuProperty
Defines the CanEffectivelyOpenSubMenu property.
public static readonly DependencyProperty CanEffectivelyOpenSubMenuProperty
CanSelectOnPointerOverProperty
Defines the CanSelectOnPointerOver property.
public static readonly DependencyProperty CanSelectOnPointerOverProperty
DescriptionProperty
Defines the Description property.
public static readonly DependencyProperty DescriptionProperty
IsInputGestureTextVisibleProperty
Defines the IsInputGestureTextVisible property.
public static readonly DependencyProperty IsInputGestureTextVisibleProperty
KeyProperty
Defines the Key property.
public static readonly DependencyProperty KeyProperty
KeyTipTextProperty
Defines the KeyTipText property.
public static readonly DependencyProperty KeyTipTextProperty
LabelProperty
Defines the Label property.
public static readonly DependencyProperty LabelProperty
LargeImageSourceProperty
Defines the LargeImageSource property.
public static readonly DependencyProperty LargeImageSourceProperty
PopupClosedCommandProperty
Defines the PopupClosedCommand property.
public static readonly DependencyProperty PopupClosedCommandProperty
PopupOpeningCommandProperty
Defines the PopupOpeningCommand property.
public static readonly DependencyProperty PopupOpeningCommandProperty
ScreenTipFooterProperty
Defines the ScreenTipFooter property.
public static readonly DependencyProperty ScreenTipFooterProperty
ScreenTipHeaderProperty
Defines the ScreenTipHeader property.
public static readonly DependencyProperty ScreenTipHeaderProperty
SmallImageSourceProperty
Defines the SmallImageSource property.
public static readonly DependencyProperty SmallImageSourceProperty
SubmenuOpeningEvent
Defines the SubmenuOpening routed event.
public static readonly RoutedEvent SubmenuOpeningEvent
TitleProperty
Defines the Title property.
public static readonly DependencyProperty TitleProperty
UseLargeSizeProperty
Defines the UseLargeSize property.
public static readonly DependencyProperty UseLargeSizeProperty