AbsoluteSith
AbsoluteSith

Reputation: 1967

How to set the height of a MenuFlyout from c# in windows 10 UWP?

I have a MenuFlyout in the c#, I want to set the height of this flyout how can I do this as it doesn't contain a Height property.

Upvotes: 0

Views: 1850

Answers (1)

Fangfang Wu - MSFT
Fangfang Wu - MSFT

Reputation: 1072

Please try this in the C# code:

private void menuFlyout_Opened(object sender, object e)
{         
    MenuFlyout m = sender as MenuFlyout;
    Style s = new Windows.UI.Xaml.Style { TargetType = typeof(MenuFlyoutPresenter) };
    s.Setters.Add(new Setter(MinHeightProperty, "800"));
    m.MenuFlyoutPresenterStyle = s;
}

This would get the same effect as in following XAML code:

 <MenuFlyout Opened="menuFlyout_Opened">
       <MenuFlyout.MenuFlyoutPresenterStyle>
           <Style TargetType="MenuFlyoutPresenter">
              <Setter Property="MinHeight" Value="800" />
           </Style>
        </MenuFlyout.MenuFlyoutPresenterStyle>
  </MenuFlyout>

Upvotes: 4

Related Questions