Change height and width of Flyout in UWP app

女生的网名这么多〃 提交于 2020-03-23 12:05:01

问题


I am using a Flyout element in my UWP app as:

<Flyout Placement="Full"/>

This opens the flyout in the centre of the app as desired. But I am unable to change the height and width of the flyout. How can this be done?


回答1:


Something like the below code should work for what you need.

private void Flyout_Opened(object sender, object e)
{         
    Flyout f = sender as Flyout;
    Style s = new Windows.UI.Xaml.Style { TargetType = typeof(FlyoutPresenter) };
    s.Setters.Add(new Setter(MinHeightProperty, "200"));        
    s.Setters.Add(new Setter(MinWidthProperty, "200"));
    f.FlyoutPresenterStyle = s;
}



回答2:


XAML equivalent to the accepted answer.
(Note: OP posted a Flyout - not a MenuFlyout):

<Flyout>
  ...
  <Flyout.FlyoutPresenterStyle>
    <Style TargetType="FlyoutPresenter">
      <Setter Property="MinWidth" Value="200" />
      <Setter Property="MinHeight" Value="200" />
    </Style>
  </Flyout.FlyoutPresenterStyle>
  ...
</Flyout>


来源:https://stackoverflow.com/questions/54901764/change-height-and-width-of-flyout-in-uwp-app

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!