Class MenuItem
Represents a selectable item inside a Menu or ContextMenu.
Inheritance
Inherited Members
Namespace: System.Windows.Controls
Assembly: OpenSilver.dll
Syntax
[StyleTypedProperty(Property = "ItemContainerStyle", StyleTargetType = typeof(MenuItem))]
public class MenuItem : HeaderedItemsControl, IControl, IFrameworkElement, IUIElement, IDependencyObject
Constructors
| Improve this Doc View SourceMenuItem()
Initializes a new instance of the MenuItem class.
Declaration
public MenuItem()
Fields
| Improve this Doc View SourceCommandParameterProperty
Identifies the CommandParameter dependency property.
Declaration
public static readonly DependencyProperty CommandParameterProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
CommandProperty
Identifies the Command dependency property.
Declaration
public static readonly DependencyProperty CommandProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
IconProperty
Identifies the Icon dependency property.
Declaration
public static readonly DependencyProperty IconProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
Properties
| Improve this Doc View SourceCommand
Gets or sets the command associated with the menu item.
Declaration
public ICommand Command { get; set; }
Property Value
Type | Description |
---|---|
System.Windows.Input.ICommand |
CommandParameter
Gets or sets the parameter to pass to the Command property of a MenuItem.
Declaration
public object CommandParameter { get; set; }
Property Value
Type | Description |
---|---|
System.Object |
Icon
Gets or sets the icon that appears in a MenuItem.
Declaration
public object Icon { get; set; }
Property Value
Type | Description |
---|---|
System.Object |
Methods
| Improve this Doc View SourceChangeVisualState(Boolean)
Changes to the correct visual state(s) for the control.
Declaration
protected virtual void ChangeVisualState(bool useTransitions)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | useTransitions | True to use transitions; otherwise false. |
OnApplyTemplate()
Called when the template's tree is generated.
Declaration
public override void OnApplyTemplate()
Overrides
| Improve this Doc View SourceOnClick()
Called when a MenuItem is clicked and raises a Click event.
Declaration
protected virtual void OnClick()
OnGotFocus(RoutedEventArgs)
Invoked whenever an unhandled GotFocus event reaches this element in its route.
Declaration
protected override void OnGotFocus(RoutedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
RoutedEventArgs | e | A RoutedEventArgs that contains event data. |
Overrides
| Improve this Doc View SourceOnItemsChanged(NotifyCollectionChangedEventArgs)
Called when the Items property changes.
Declaration
protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Specialized.NotifyCollectionChangedEventArgs | e | The event data for the ItemsChanged event. |
Overrides
| Improve this Doc View SourceOnKeyDown(KeyEventArgs)
Responds to the KeyDown event.
Declaration
protected override void OnKeyDown(KeyEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
KeyEventArgs | e | The event data for the KeyDown event. |
Overrides
| Improve this Doc View SourceOnLostFocus(RoutedEventArgs)
Raises the LostFocus routed event by using the event data that is provided.
Declaration
protected override void OnLostFocus(RoutedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
RoutedEventArgs | e | A RoutedEventArgs that contains event data. |
Overrides
| Improve this Doc View SourceOnMouseEnter(MouseEventArgs)
Called whenever the mouse enters a MenuItem.
Declaration
protected override void OnMouseEnter(MouseEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
MouseEventArgs | e | The event data for the MouseEnter event. |
Overrides
| Improve this Doc View SourceOnMouseLeave(MouseEventArgs)
Called whenever the mouse leaves a MenuItem.
Declaration
protected override void OnMouseLeave(MouseEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
MouseEventArgs | e | The event data for the MouseLeave event. |
Overrides
| Improve this Doc View SourceOnMouseLeftButtonDown(MouseButtonEventArgs)
Called when the left mouse button is pressed.
Declaration
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
MouseButtonEventArgs | e | The event data for the MouseLeftButtonDown event. |
Overrides
| Improve this Doc View SourceOnMouseRightButtonDown(MouseButtonEventArgs)
Called when the right mouse button is pressed.
Declaration
protected override void OnMouseRightButtonDown(MouseButtonEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
MouseButtonEventArgs | e | The event data for the MouseRightButtonDown event. |
Overrides
Events
| Improve this Doc View SourceClick
Occurs when a MenuItem is clicked.
Declaration
public event RoutedEventHandler Click
Event Type
Type | Description |
---|---|
RoutedEventHandler |