UWP - 按钮弹出窗口以某种方式锁定了高度

UWP - Button flyout is somehow height locked

我无法解决这个错误,所以我将其剥离到仍然存在的最简单版本。

这是我的 XAML 代码:

<Grid>
    <Button x:Name="button1" Content="Button" VerticalAlignment="Top">
        <Button.Flyout>
            <Flyout Placement="Right">
                <Flyout.FlyoutPresenterStyle>
                    <Style TargetType="FlyoutPresenter">
                        <Setter Property="Padding" Value="0"/>
                        <Setter Property="Margin" Value="0"/>
                        <Setter Property="BorderThickness" Value="0"/>
                    </Style>
                </Flyout.FlyoutPresenterStyle>
                <Grid Name="PopupGrid" Background="Aqua"/>
            </Flyout>
        </Button.Flyout>
    </Button>
</Grid>

然后我为那个页面准备了一个活动:

private void Page_SizeChanged(object sender, SizeChangedEventArgs e)
{
    PopupGrid.Height = Window.Current.Bounds.Height;
}

因此该代码的预期行为如下:按下按钮后,将打开一个弹出窗口,该弹出窗口在 window 上垂直延伸。这完美地工作,直到我让我的 window 太高。 Here's 我所描述内容的 GIF。

正如你所看到的,弹出窗口显然认为它应该是 window 的高度,但由于某种原因它只是在某个点停止扩展,并添加了一个滚动条。

我是不是没看到什么?还是这些 Flyout 有一些我从未听说过的任意最大高度?

弹出窗口确实有最大高度限制。在 FlyoutPresenter styles and templates, you can find FlyoutPresenter 中有一个 MaxHeight 属性 设置为 FlyoutThemeMaxHeight:

<Setter Property="MinWidth" Value="{ThemeResource FlyoutThemeMinWidth}"/>
<Setter Property="MaxWidth" Value="{ThemeResource FlyoutThemeMaxWidth}"/>
<Setter Property="MinHeight" Value="{ThemeResource FlyoutThemeMinHeight}"/>
<Setter Property="MaxHeight" Value="{ThemeResource FlyoutThemeMaxHeight}"/>

FlyoutThemeMaxHeight是一个主题资源代表758:

<x:Double x:Key="FlyoutThemeMaxHeight">758</x:Double>

您可以尝试将 FlyoutPresenterMaxHeight 重置为 PositiveInfinity(可以在 XAML 中简单地设置为“Infinity") 就像下面那么网格应该能够在 window.

上垂直拉伸
<Button x:Name="button1" VerticalAlignment="Top" Content="Button">
    <Button.Flyout>
        <Flyout Placement="Right">
            <Flyout.FlyoutPresenterStyle>
                <Style TargetType="FlyoutPresenter">
                    <Setter Property="Padding" Value="0" />
                    <Setter Property="Margin" Value="0" />
                    <Setter Property="BorderThickness" Value="0" />
                    <Setter Property="MaxHeight" Value="Infinity" />
                </Style>
            </Flyout.FlyoutPresenterStyle>
            <Grid Name="PopupGrid" Background="Aqua" />
        </Flyout>
    </Button.Flyout>
</Button>