0

是否有一些技巧可以使 WinRT 中的 Page.AppBars 挤压/移动页面的内容而不是越过内容的顶部?

4

1 回答 1

2

你可以,但你需要编写一些代码来做到这一点。

我的版本使用视觉状态:

<Page.BottomAppBar>
    <AppBar
        x:Name="bottomAppBar"
        Opened="OnBottomAppBarOpened"
        Closed="OnBottomAppBarClosed">
        <StackPanel
            Orientation="Horizontal">
            <Button
                Style="{StaticResource PlayAppBarButtonStyle}" />
        </StackPanel>
    </AppBar>
</Page.BottomAppBar>
<Grid
    Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
    <VisualStateManager.VisualStateGroups>
        <VisualStateGroup
            x:Name="AppBarPushStates">
            <VisualState
                x:Name="AppBarClosed">
                <Storyboard>
                    <DoubleAnimation
                        Storyboard.TargetName="pushedContentTransform"
                        Storyboard.TargetProperty="Y"
                        To="0"
                        Duration="0:0:0.2">
                        <DoubleAnimation.EasingFunction>
                            <CubicEase
                                EasingMode="EaseOut" />
                        </DoubleAnimation.EasingFunction>
                    </DoubleAnimation>
                </Storyboard>
            </VisualState>
            <VisualState
                x:Name="AppBarOpened">
                <Storyboard>
                    <DoubleAnimation
                        Storyboard.TargetName="pushedContentTransform"
                        Storyboard.TargetProperty="Y"
                        To="-88"
                        Duration="0:0:0.2">
                        <DoubleAnimation.EasingFunction>
                            <CubicEase
                                EasingMode="EaseOut" />
                        </DoubleAnimation.EasingFunction>
                    </DoubleAnimation>
                </Storyboard>
            </VisualState>
        </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>
    <Border
        VerticalAlignment="Stretch"
        HorizontalAlignment="Stretch"
        BorderBrush="Orange"
        BorderThickness="5">
        <Border.RenderTransform>
            <TranslateTransform
                x:Name="pushedContentTransform" />
        </Border.RenderTransform>
        <TextBox
            TextWrapping="Wrap"
            Foreground="Brown"
            FontSize="48"
            Text="Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna. Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci. Aenean nec lorem. In porttitor. Donec laoreet nonummy augue. Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy. Fusce aliquet pede non pede. Suspendisse dapibus lorem pellentesque magna. Integer nulla. Donec blandit feugiat ligula. Donec hendrerit, felis et imperdiet euismod, purus ipsum pretium metus, in lacinia nulla nisl eget sapien. Donec ut est in lectus consequat consequat." />
    </Border>
</Grid>

后面的代码:

    private void OnBottomAppBarClosed(object sender, object e)
    {
        VisualStateManager.GoToState(this, "AppBarClosed", true);
    }

    private void OnBottomAppBarOpened(object sender, object e)
    {
        VisualStateManager.GoToState(this, "AppBarOpened", true);
    }
于 2012-08-05T21:17:34.283 回答