如何将网格填充到窗户的高度?

时间:2016-01-30 19:40:06

标签: xaml grid uwp

这是我的页面模板:     

<Page.Resources>
    <Storyboard x:Name="Show">
        <DoubleAnimation Duration="0:0:1.5" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="CuurentTarget" d:IsOptimized="True"/>
    </Storyboard>
</Page.Resources>


<Grid Style="{StaticResource JagermasterBackground}" VerticalAlignment="Stretch">
    <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="VisualStateGroup">
            <VisualState x:Name="PortraitOrientation">
                <VisualState.StateTriggers>
                    <AdaptiveTrigger MinWindowWidth="600"/>
                </VisualState.StateTriggers>
                <VisualState.Setters>
                    <Setter Target="FluidPanel.(UIElement.Orientation)" Value="Horizontal"/>
                </VisualState.Setters>
            </VisualState>
            <VisualState x:Name="LandscapeOrientation"/>
        </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="Auto" />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition />
    </Grid.RowDefinitions>
    <StackPanel Style="{StaticResource JagermasterSimpleStack}">
        <TextBlock Name="CuurentTarget" Style="{StaticResource JagermasterText}" Text="{Binding Path=CurrentTarget}">
        </TextBlock>
        <Button Name="AdventureTimeButton" Style="{StaticResource JagermasterButton}" Content="Готов к новым приключениям" Click="ButtonBase_OnClick"/>
    </StackPanel>
    <StackPanel Grid.Column="0" Grid.Row="1" x:Name="FluidPanel" Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center" >
        <SymbolIcon Symbol="List" Style="{StaticResource JagermasterSymbol}" Tapped="ListShowOrHide" Margin="5"/>
        <local:TargetsListManage x:Name="TargetsListManager"/>
    </StackPanel>
</Grid>

当我按下&#34;恢复&#34; grid(root)不填充窗口。底部只是停留在窗口的边界之外而没有滚动。我想在这种情况下我可以为MaxSize添加一个绑定。我希望有另一种解决方案。 以下是解释的屏幕截图:as expectunexpect

1 个答案:

答案 0 :(得分:0)

如果我找到了你,你会想要一个像页脚一样的东西,无论你的窗口是什么样的,它总是停留在底部。这是对的吗?

如果是这样,这可能是您的解决方案:

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>

    <!--  Header  -->
    <Grid Grid.Row="0">
        <!--  Place all header here  -->
    </Grid>

    <!--  Content  -->
    <Grid Grid.Row="1">
        <!--  Place all your scrollable elements here  -->
    </Grid>

    <!--  Footer  -->
    <Grid Grid.Row="2">
        <!--  Place everything that needs to stay at the bottom here  -->
    </Grid>
</Grid>

通过定义<RowDefinition/>元素,您可以为您的子元素提供特殊高度,例如Auto(占用您需要的空间)和*(占用剩余空间)。

那就是你需要的吗?