MenuFlyoutItem MenuFlyoutItem MenuFlyoutItem Class

Definition

Represents a command in a MenuFlyout control.

public class MenuFlyoutItem : MenuFlyoutItemBase, IMenuFlyoutItem, IMenuFlyoutItem2public class MenuFlyoutItem : MenuFlyoutItemBase, IMenuFlyoutItem, IMenuFlyoutItem2Public Class MenuFlyoutItem Inherits MenuFlyoutItemBase Implements IMenuFlyoutItem, IMenuFlyoutItem2
<MenuFlyoutItem .../>
-or-
<MenuFlyoutItem>string</MenuFlyoutItem>
Inheritance
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Inherited Members

Inherited properties

Inherited events

Inherited methods

Remarks

Use a Flyout control to display single items and a MenuFlyout control to show a menu of items.

MenuFlyoutItem is the parent class for ToggleMenuFlyoutItem.

Control style and template

You can modify the default Style and ControlTemplate to give the control a unique appearance. For information about modifying a control's style and template, see Styling controls. The default style, template, and resources that define the look of the control are included in the generic.xaml file. For design purposes, generic.xaml is available in the (Program Files)\Windows Kits\10\DesignTime\CommonConfiguration\Neutral\UAP&lt;SDK version>\Generic folder from a Windows Software Development Kit (SDK) installation. Styles and resources from different versions of the SDK might have different values.

Starting in Windows 10, version 1607 (Windows Software Development Kit (SDK) version 10.0.14393.0), generic.xaml includes resources that you can use to modify the colors of a control in different visual states without modifying the control template. In apps that target this software development kit (SDK) or later, modifying these resources is preferred to setting properties such as Background and Foreground. For more info, see the Light-weight styling section of the Styling controls article.

This table shows the resources used by the MenuFlyoutItem control.

Resource keyDescription
MenuFlyoutItemBackgroundBackground color of entire control bounds at rest
MenuFlyoutItemBackgroundPointerOverBackground color on hover
MenuFlyoutItemBackgroundPressedBackground color when pressed
MenuFlyoutItemBackgroundDisabledBackground color when disabled
MenuFlyoutItemForegroundText color at rest
MenuFlyoutItemForegroundPointerOverText color on hover
MenuFlyoutItemForegroundPressedText color when pressed
MenuFlyoutItemForegroundDisabledText color when disabled

Constructors

MenuFlyoutItem() MenuFlyoutItem() MenuFlyoutItem()

Initializes a new instance of the MenuFlyoutItem class.

public MenuFlyoutItem()public MenuFlyoutItem()Public Sub New()
Attributes

Properties

Command Command Command

Gets or sets the command to invoke when the item is pressed.

public ICommand Command { get; set; }public ICommand Command { get; set; }Public ReadWrite Property Command As ICommand
<MenuFlyoutItem Command="commandReference"/>
Value
ICommand ICommand ICommand

The command to invoke when the item is pressed. The default is null.

Attributes

Remarks

The ICommand interface comes from a different source depending on whether the data source is implemented in Visual C++ component extensions (C++/CX) or for Microsoft .NET. Visual C++ component extensions (C++/CX) implements Windows::UI::Xaml::Input::ICommand. Microsoft .NET implements System.Windows.Input.ICommand. Both interfaces have the same template. Which interface you call from your app code is analogous: use Windows::UI::Xaml::Input::ICommand for Visual C++ component extensions (C++/CX) code and System.Windows.Input.ICommand for Microsoft .NET code.

The XAML syntax shown for Microsoft .NET 's System.Windows.Input.ICommand type does not work for Windows Runtime XAML. You should always use a Binding reference. Constructs such as named commands and x:Static are not supported.

CommandParameter CommandParameter CommandParameter

Gets or sets the parameter to pass to the Command property.

public object CommandParameter { get; set; }public object CommandParameter { get; set; }Public ReadWrite Property CommandParameter As object
<MenuFlyoutItem>
  <MenuFlyoutItem.CommandParameter>
    object
  </MenuFlyoutItem.CommandParameter>
</MenuFlyoutItem>
Value
object object object

The parameter to pass to the Command property. The default is null.

Attributes

CommandParameterProperty CommandParameterProperty CommandParameterProperty

Identifies the CommandParameter dependency property.

public static DependencyProperty CommandParameterProperty { get; }public static DependencyProperty CommandParameterProperty { get; }Public Static ReadOnly Property CommandParameterProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the CommandParameter dependency property.

Attributes

CommandProperty CommandProperty CommandProperty

Identifies the Command dependency property.

public static DependencyProperty CommandProperty { get; }public static DependencyProperty CommandProperty { get; }Public Static ReadOnly Property CommandProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the Command dependency property.

Attributes

Icon Icon Icon

Gets or sets the graphic content of the menu flyout item.

public IconElement Icon { get; set; }public IconElement Icon { get; set; }Public ReadWrite Property Icon As IconElement
<MenuFlyoutItem Icon="symbolName" .../>
Value
IconElement IconElement IconElement

The graphic content of the menu flyout item.

Attributes

IconProperty IconProperty IconProperty

Identifies the Icon dependency property.

public static DependencyProperty IconProperty { get; }public static DependencyProperty IconProperty { get; }Public Static ReadOnly Property IconProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the Icon dependency property.

Attributes

Text Text Text

Gets or sets the text content of a MenuFlyoutItem.

public string Text { get; set; }public string Text { get; set; }Public ReadWrite Property Text As string
<MenuFlyoutItem Text="string"/>
Value
string string string

A string that specifies the text content of this MenuFlyoutItem. The default is an empty string.

Attributes

TextProperty TextProperty TextProperty

Identifies the Text dependency property.

public static DependencyProperty TextProperty { get; }public static DependencyProperty TextProperty { get; }Public Static ReadOnly Property TextProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the Text dependency property.

Attributes

Events

Click Click Click

Occurs when a menu item is clicked.

public event RoutedEventHandler Clickpublic event RoutedEventHandler ClickPublic Event Click
<MenuFlyoutItem Click="eventhandler"/>
Attributes
See Also

See Also