-api-id | -api-type |
---|---|
T:Windows.UI.Xaml.Controls.MenuFlyoutPresenter |
winrt class |
Displays the content of a MenuFlyout control.
You don't typically use a MenuFlyoutPresenter directly, either in XAML or code. Instead, you reference the MenuFlyoutPresenter type as the TargetType of the style you use for the MenuFlyout.MenuFlyoutPresenterStyle property. Then, you use style Setter elements to set the various Control properties that influence the appearance of the MenuFlyout through this presenter. For example you can use a Setter to set the Width of the MenuFlyout:
<MenuFlyout x:Name="optionFlyout">
<MenuFlyout.MenuFlyoutPresenterStyle>
<Style TargetType="MenuFlyoutPresenter">
<Setter Property="Width" Value="300"/>
</Style>
</MenuFlyout.MenuFlyoutPresenterStyle>
<!--menu items go here-->
</MenuFlyout>
The MenuFlyoutPresenter class is not a ContentPresenter derived class, it's actually a control (derived from ItemsControl) that plays a special role when creating the visual tree for a MenuFlyout.
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 locally with the SDK or NuGet package installation.
- WinUI Styles (recommended): For updated styles from WinUI, see
\Users\<username>\.nuget\packages\microsoft.ui.xaml\<version>\lib\uap10.0\Microsoft.UI.Xaml\Themes\generic.xaml
. - Non-WinUI styles: For built-in styles, see
%ProgramFiles(x86)%\Windows Kits\10\DesignTime\CommonConfiguration\Neutral\UAP\<SDK version>\Generic\generic.xaml
.
Locations might be different if you customized the installation. Styles and resources from different versions of the SDK might have different values.
XAML also includes resources that you can use to modify the colors of a control in different visual states without modifying the control template. Modifying these resources is preferred to setting properties such as Background and Foreground. For more info, see the Light-weight styling section of the XAML styles article. Light-weight styling resources are available starting in Windows 10, version 1607 (SDK 14393).
Windows version | SDK version | Value added |
---|---|---|
1511 | 10586 | TemplateSettings |
1903 | 18362 | IsDefaultShadowEnabled |