MenuFlyout MenuFlyout MenuFlyout Class

Definition

Represents a flyout that displays a menu of commands.

public : class MenuFlyout : FlyoutBase, IMenuFlyout, IMenuFlyout2
public class MenuFlyout : FlyoutBase, IMenuFlyout, IMenuFlyout2
Public Class MenuFlyout Inherits FlyoutBase Implements IMenuFlyout, IMenuFlyout2
<MenuFlyout>
  oneOrMoreItems
</MenuFlyout>
Inheritance
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

XAML Controls Gallery
XAML controls gallery

If you have the XAML Controls Gallery app installed, click here to open the app and see the MenuFlyout in action.

Remarks

MenuFlyout temporarily displays a list of commands or options related to what the user is currently doing.

Menu flyout control

Use a Flyout control to display single items and a MenuFlyout control to show a menu of items. For more info, see Menus and context menus.

A MenuFlyout control can be used as the value of the Button.Flyout property. This is usually set in XAML as part of a UI definition of the page. Button is the only control that has a dedicated Flyout property. To associate a MenuFlyout with other controls, use the FlyoutBase.AttachedFlyout attached property. When set as Button.Flyout, the MenuFlyout displays when the button is tapped or otherwise invoked. When a MenuFlyout is assigned to other UI elements using FlyoutBase.AttachedFlyout, you must call either the ShowAt method or the static ShowAttachedFlyout method to display the flyout.

In addition to the members listed above, there are other members of the base class FlyoutBase that are often used in typical MenuFlyout scenarios:

Constructors

MenuFlyout() MenuFlyout() MenuFlyout()

Initializes a new instance of the MenuFlyout class.

public : MenuFlyout()
public MenuFlyout()
Public Sub New()

Properties

AllowFocusOnInteraction AllowFocusOnInteraction AllowFocusOnInteraction

Gets or sets a value that indicates whether the element automatically gets focus when the user interacts with it.

(Inherited from FlyoutBase)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

AllowFocusOnInteractionProperty AllowFocusOnInteractionProperty AllowFocusOnInteractionProperty

Identifies the AllowFocusOnInteraction dependency property.

(Inherited from FlyoutBase)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

AllowFocusWhenDisabled AllowFocusWhenDisabled AllowFocusWhenDisabled

Gets or sets a value that specifies whether the control can receive focus when it's disabled.

(Inherited from FlyoutBase)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

AllowFocusWhenDisabledProperty AllowFocusWhenDisabledProperty AllowFocusWhenDisabledProperty

Identifies the AllowFocusWhenDisabled dependency property.

(Inherited from FlyoutBase)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

AttachedFlyoutProperty AttachedFlyoutProperty AttachedFlyoutProperty

Identifies the FlyoutBase.AttachedFlyout XAML attached property.

(Inherited from FlyoutBase)

Dispatcher Dispatcher Dispatcher

Gets the CoreDispatcher that this object is associated with. The CoreDispatcher represents a facility that can access the DependencyObject on the UI thread even if the code is initiated by a non-UI thread.

(Inherited from DependencyObject)

ElementSoundMode ElementSoundMode ElementSoundMode

Gets or sets a value that specifies the control's preference for whether it plays sounds.

(Inherited from FlyoutBase)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

ElementSoundModeProperty ElementSoundModeProperty ElementSoundModeProperty

Identifies the ElementSoundMode dependency property.

(Inherited from FlyoutBase)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Items Items Items

Gets the collection used to generate the content of the menu.

public : IVector<MenuFlyoutItemBase> Items { get; }
public IList<MenuFlyoutItemBase> Items { get; }
Public ReadOnly Property Items As IList<MenuFlyoutItemBase>
<MenuFlyout>
  oneOrMoreItems
</MenuFlyout>
Value
IVector<MenuFlyoutItemBase> IList<MenuFlyoutItemBase> IList<MenuFlyoutItemBase>

The collection that is used to generate the content of the menu, if it exists; otherwise, null. The default is an empty collection.

See Also

LightDismissOverlayMode LightDismissOverlayMode LightDismissOverlayMode

Gets or sets a value that specifies whether the area outside of a light-dismiss UI is darkened.

(Inherited from FlyoutBase)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

LightDismissOverlayModeProperty LightDismissOverlayModeProperty LightDismissOverlayModeProperty

Identifies the LightDismissOverlayMode dependency property.

(Inherited from FlyoutBase)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

MenuFlyoutPresenterStyle MenuFlyoutPresenterStyle MenuFlyoutPresenterStyle

Gets or sets the style that is used when rendering the MenuFlyout.

public : Style MenuFlyoutPresenterStyle { get; set; }
public Style MenuFlyoutPresenterStyle { get; set; }
Public ReadWrite Property MenuFlyoutPresenterStyle As Style
<MenuFlyout MenuFlyoutPresenterStyle="resourceReferenceToStyle"/>
Value
Style Style Style

The style that is used when rendering the MenuFlyout.

Remarks

The TargetType value to use for the Style must be MenuFlyoutPresenter (not MenuFlyout).

You can't style a MenuFlyout directly. Instead, you apply a style to the MenuFlyoutPresenter that provides the visuals for the flyout. You can also style MenuFlyoutItem and ToggleMenuFlyoutItem (they are controls) and you can use implicit styles to do so. Or, you can set UI-related properties on the MenuFlyoutItem and ToggleMenuFlyoutItem items directly.

See Also

MenuFlyoutPresenterStyleProperty MenuFlyoutPresenterStyleProperty MenuFlyoutPresenterStyleProperty

Identifies the MenuFlyoutPresenterStyle dependency property.

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

The identifier for the MenuFlyoutPresenterStyle dependency property.

OverlayInputPassThroughElement OverlayInputPassThroughElement OverlayInputPassThroughElement

Gets or sets an element that should receive pointer input events even when underneath the flyout's overlay.

(Inherited from FlyoutBase)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

OverlayInputPassThroughElementProperty OverlayInputPassThroughElementProperty OverlayInputPassThroughElementProperty

Identifies the OverlayInputPassThroughElement dependency property.

(Inherited from FlyoutBase)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

Placement Placement Placement

Gets or sets the default placement to be used for the flyout, in relation to its placement target.

(Inherited from FlyoutBase)

PlacementProperty PlacementProperty PlacementProperty

Identifies the Placement dependency property.

(Inherited from FlyoutBase)

Target Target Target

Gets the element to use as the flyout's placement target.

(Inherited from FlyoutBase)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Methods

ClearValue(DependencyProperty) ClearValue(DependencyProperty) ClearValue(DependencyProperty)

Clears the local value of a dependency property.

(Inherited from DependencyObject)

CreatePresenter CreatePresenter CreatePresenter

When overridden in a derived class, initializes a control to show the flyout content as appropriate for the derived control. Note: This method has no base class implementation and must be overridden in a derived class.

(Inherited from FlyoutBase)

GetAnimationBaseValue(DependencyProperty) GetAnimationBaseValue(DependencyProperty) GetAnimationBaseValue(DependencyProperty)

Returns any base value established for a dependency property, which would apply in cases where an animation is not active.

(Inherited from DependencyObject)

GetAttachedFlyout(FrameworkElement) GetAttachedFlyout(FrameworkElement) GetAttachedFlyout(FrameworkElement)

Gets the flyout associated with the specified element.

(Inherited from FlyoutBase)

GetValue(DependencyProperty) GetValue(DependencyProperty) GetValue(DependencyProperty)

Returns the current effective value of a dependency property from a DependencyObject.

(Inherited from DependencyObject)

Hide Hide Hide

Closes the flyout.

(Inherited from FlyoutBase)

OnProcessKeyboardAccelerators(ProcessKeyboardAcceleratorEventArgs) OnProcessKeyboardAccelerators(ProcessKeyboardAcceleratorEventArgs) OnProcessKeyboardAccelerators(ProcessKeyboardAcceleratorEventArgs)

Called just before a keyboard shortcut (accelerator) is processed in your app. Invoked whenever application code or internal processes call ProcessKeyboardAccelerators. Override this method to influence the default accelerator handling.

(Inherited from FlyoutBase)
Additional features and requirements
Device family
Windows 10 Fall Creators Update (introduced v10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty)

Returns the local value of a dependency property, if a local value is set.

(Inherited from DependencyObject)

RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback) RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback) RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback)

Registers a notification function for listening to changes to a specific DependencyProperty on this DependencyObject instance.

(Inherited from DependencyObject)

SetAttachedFlyout(FrameworkElement,FlyoutBase) SetAttachedFlyout(FrameworkElement,FlyoutBase) SetAttachedFlyout(FrameworkElement,FlyoutBase)

Associates the specified flyout with the specified FrameworkElement.

(Inherited from FlyoutBase)

SetValue(DependencyProperty,Object) SetValue(DependencyProperty,Object) SetValue(DependencyProperty,Object)

Sets the local value of a dependency property on a DependencyObject.

(Inherited from DependencyObject)

ShowAt(FrameworkElement) ShowAt(FrameworkElement) ShowAt(FrameworkElement)

Shows the flyout placed in relation to the specified element.

(Inherited from FlyoutBase)

ShowAt(UIElement, Point) ShowAt(UIElement, Point) ShowAt(UIElement, Point)

Shows the flyout placed at the specified offset in relation to the specified target element.

public : void ShowAt(UIElement targetElement, Point point)
public void ShowAt(UIElement targetElement, Point point)
Public Function ShowAt(targetElement As UIElement, point As Point) As void
Parameters
targetElement
UIElement UIElement UIElement

The element to use as the flyout's placement target.

point
Point Point Point

The point at which to offset the flyout from the specified target element.

Examples

To position the menu relative to a UI element, specify the element and offset.

MenuFlyout.ShowAt(element, new Point(0,0));

To position the menu relative to the application window, set the targetElement parameter to null.

MenuFlyout.ShowAt(null, new Point(x, y));

Remarks

When you call this method to show a MenuFlyout, it automatically renders outside the application window if possible and required.

Some properties might not flow as expected, such as FlowDirection. To ensure correct flow, you can set the flow direction in the MenuFlyoutPresenter The MenuFlyoutPresenter must be set before the MenuFlyout is first shown.

See Also

ShowAttachedFlyout(FrameworkElement) ShowAttachedFlyout(FrameworkElement) ShowAttachedFlyout(FrameworkElement)

Shows the flyout associated with the specified element, if any.

(Inherited from FlyoutBase)

TryInvokeKeyboardAccelerator(ProcessKeyboardAcceleratorEventArgs) TryInvokeKeyboardAccelerator(ProcessKeyboardAcceleratorEventArgs) TryInvokeKeyboardAccelerator(ProcessKeyboardAcceleratorEventArgs)

Attempts to invoke a keyboard shortcut (accelerator).

(Inherited from FlyoutBase)
Additional features and requirements
Device family
Windows 10 Fall Creators Update (introduced v10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

UnregisterPropertyChangedCallback(DependencyProperty,Int64) UnregisterPropertyChangedCallback(DependencyProperty,Int64) UnregisterPropertyChangedCallback(DependencyProperty,Int64)

Cancels a change notification that was previously registered by calling RegisterPropertyChangedCallback.

(Inherited from DependencyObject)

Events

Closed Closed Closed

Occurs when the flyout is hidden.

(Inherited from FlyoutBase)

Closing Closing Closing

Occurs when the flyout starts to be hidden.

(Inherited from FlyoutBase)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Opened Opened Opened

Occurs when the flyout is shown.

(Inherited from FlyoutBase)

Opening Opening Opening

Occurs before the flyout is shown.

(Inherited from FlyoutBase)

See Also