问题
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