MenuFlyoutItem MenuFlyoutItem MenuFlyoutItem Class

Represents a command in a MenuFlyout control.

Syntax

Declaration

public class MenuFlyoutItempublic class MenuFlyoutItemPublic Class MenuFlyoutItem
<MenuFlyoutItem .../>
-or-
<MenuFlyoutItem>string</MenuFlyoutItem>

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 summary

Initializes a new instance of the MenuFlyoutItem class.

Properties summary

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

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

Identifies the CommandParameter dependency property.

Identifies the Command dependency property.

Gets or sets the text content of a MenuFlyoutItem.

Identifies the Text dependency property.

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

Prerelease. Identifies the Icon dependency property.

Events summary

Occurs when a menu item is clicked.

Constructors

  • MenuFlyoutItem()
    MenuFlyoutItem()
    MenuFlyoutItem()
    MenuFlyoutItem()

    Initializes a new instance of the MenuFlyoutItem class.

    public MenuFlyoutItem()public MenuFlyoutItem()Public Function MenuFlyoutItem() As

Properties

  • Command
    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"/>
    

    Property Value

    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 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 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
    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>
    

    Property Value

    • object
      object
      object

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

  • CommandParameterProperty
    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

    Property Value

  • CommandProperty
    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

    Property Value

  • Text
    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"/>
    

    Property Value

    • string
      string
      string

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

  • TextProperty
    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

    Property Value

  • Icon
    Icon
    Icon
    Icon

    Prerelease. 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" .../>
    

    Property Value

  • IconProperty
    IconProperty
    IconProperty
    IconProperty

    Prerelease. Identifies the Icon dependency property.

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

    Property Value

Events

  • Click
    Click
    Click
    Click

    Occurs when a menu item is clicked.

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

Attributes

Windows.Foundation.Metadata.StaticAttribute
Windows.Foundation.Metadata.ComposableAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.ThreadingAttribute
Windows.Foundation.Metadata.WebHostHiddenAttribute
Windows.UI.Xaml.Markup.ContentPropertyAttribute
Windows.Foundation.Metadata.StaticAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute

Details

Assembly

Windows.UI.Xaml.Controls.dll