Table of Contents

Class NativeMenuItem

Namespace
Avalonia.Controls
Assembly
Avalonia.Controls.dll
public class NativeMenuItem : NativeMenuItemBase, INotifyPropertyChanged, INativeMenuItemExporterEventsImplBridge
Inheritance
NativeMenuItem
Implements
Derived
Inherited Members

Constructors

NativeMenuItem()

public NativeMenuItem()

NativeMenuItem(string)

public NativeMenuItem(string header)

Parameters

header string

Fields

CommandParameterProperty

Defines the CommandParameter property.

public static readonly StyledProperty<object?> CommandParameterProperty

Field Value

StyledProperty<object>

CommandProperty

Defines the Command property.

public static readonly StyledProperty<ICommand?> CommandProperty

Field Value

StyledProperty<ICommand>

GestureProperty

Defines the InputGesture property.

public static readonly StyledProperty<KeyGesture?> GestureProperty

Field Value

StyledProperty<KeyGesture>

HeaderProperty

Defines the Header property.

public static readonly StyledProperty<string?> HeaderProperty

Field Value

StyledProperty<string>

IconProperty

Defines the Icon property.

public static readonly StyledProperty<Bitmap?> IconProperty

Field Value

StyledProperty<Bitmap>

IsCheckedProperty

Defines the IsChecked property.

public static readonly StyledProperty<bool> IsCheckedProperty

Field Value

StyledProperty<bool>

IsEnabledProperty

Defines the IsEnabled property.

public static readonly StyledProperty<bool> IsEnabledProperty

Field Value

StyledProperty<bool>

IsVisibleProperty

Defines the IsVisible property.

public static readonly StyledProperty<bool> IsVisibleProperty

Field Value

StyledProperty<bool>

MenuProperty

public static readonly StyledProperty<NativeMenu?> MenuProperty

Field Value

StyledProperty<NativeMenu>

ToggleTypeProperty

Defines the ToggleType property.

public static readonly StyledProperty<NativeMenuItemToggleType> ToggleTypeProperty

Field Value

StyledProperty<NativeMenuItemToggleType>

ToolTipProperty

Defines the ToolTip property.

public static readonly StyledProperty<string?> ToolTipProperty

Field Value

StyledProperty<string>

Properties

Command

Gets or sets the command associated with the menu item.

public ICommand? Command { get; set; }

Property Value

ICommand

CommandParameter

Gets or sets the parameter to pass to the Command property of a MenuItem.

public object? CommandParameter { get; set; }

Property Value

object

Gesture

Gets or sets the input gesture that will be displayed in the menu item.

public KeyGesture? Gesture { get; set; }

Property Value

KeyGesture

Remarks

Setting this property does not cause the input gesture to be handled by the menu item, it simply displays the gesture text in the menu.

HasClickHandlers

public bool HasClickHandlers { get; }

Property Value

bool

Header

Gets or sets the content of the control's header.

public string? Header { get; set; }

Property Value

string

Icon

Gets or sets the icon that appears in a MenuItem.

public Bitmap? Icon { get; set; }

Property Value

Bitmap

IsChecked

Gets or sets if menu item is checked when ToggleType is CheckBox or Radio.

public bool IsChecked { get; set; }

Property Value

bool

IsEnabled

Gets or sets a value indicating whether the control is enabled for user interaction.

public bool IsEnabled { get; set; }

Property Value

bool

IsVisible

Gets or sets a value indicating whether this menu item is visible.

public bool IsVisible { get; set; }

Property Value

bool

Menu

[Content]
public NativeMenu? Menu { get; set; }

Property Value

NativeMenu

ToggleType

Gets toggle type of the menu item.

public NativeMenuItemToggleType ToggleType { get; set; }

Property Value

NativeMenuItemToggleType

ToolTip

Gets or sets the tooltip associated with the menu item. This may not be supported by the native menu provider, but will be passed on to the non-native fallback menu item if used.

public string? ToolTip { get; set; }

Property Value

string

Methods

OnPropertyChanged(AvaloniaPropertyChangedEventArgs)

Called when a avalonia property changes on the object.

protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)

Parameters

change AvaloniaPropertyChangedEventArgs

The property change details.

Events

Click

Occurs when a NativeMenuItem is clicked.

public event EventHandler? Click

Event Type

EventHandler