Search code examples
c#uwpuwp-xamlwinui

How to set the height for menuFlyoutSubItem generated menuFlyout in uwp?


How to set the height for the MenuFlyoutSubItem's -> MenuFlyout height in uwp?

Sample Image is attached below,

Sample Image


Solution

  • You can check MenuFlyout theme resources, there is only the property MinHeight in MenuFlyoutPresenter to modify the height, but this will apply to all MenuFlyoutSubItem, and the height cannot be set individually for one SubItem.

    private void MenuFlyout_Opened(object sender, object e)
    {
        MenuFlyout menuFlyout = sender as MenuFlyout;
        Style style = new Style { TargetType = typeof(MenuFlyoutPresenter) };
        style.Setters.Add(new Setter(MinHeightProperty, "500"));
        menuFlyout.MenuFlyoutPresenterStyle = style;
    }