跳到主要内容
版本:11.0.0

Native Menu

The native menu can display a menu on macOS and some Linux distributions.

注意

This control can only be used attached to a tray icon. For full details about the tray icon, see the reference here.

You can create sub-menus by nesting <MenuItem> elements.

You can add menu separator lines by including a <NativeMenuItemSeparator> element or by adding a menu item with its header set to the minus sign, like this:

<NativeMenuItemSeparator Header="-" />

Useful Properties

You will probably use these properties most often:

PropertyDescription
HeaderThe menu caption.
CommandA command to execute when the user clicks the menu item.

Example

This example defines a native menu that can be attached to a tray icon:

<NativeMenu>
<NativeMenuItem Header="Settings">
<NativeMenu>
<NativeMenuItem Header="Option 1" />
<NativeMenuItem Header="Option 2" />
<NativeMenuItemSeparator />
<NativeMenuItem Header="Option 3" />
</NativeMenu>
</NativeMenuItem>
</NativeMenu>

More Information

信息

For the complete API documentation about this control, see here.

信息

View the source code on GitHub NativeMenu.cs