WP7 - 显示隐藏应用程序栏

时间:2011-01-14 06:09:41

标签: windows-phone-7

在许多Windows Phone 7应用程序中,默认情况下隐藏应用程序栏,当您按住屏幕时,应用程序栏会显示。由于许多WP7应用程序都有这种行为,我想知道,如果使用ApplicationBar有这种行为的内置支持,我该如何使用它呢?

2 个答案:

答案 0 :(得分:6)

您可以使用toolkit中的GestureService来检测Hold事件。

例如。
如果你在页面上有这个xaml:

<TextBlock TextWrapping="Wrap" Text="lorem ipsum ...">
    <toolkit:GestureService.GestureListener>
        <toolkit:GestureListener Hold="TapAndHold" />
    </toolkit:GestureService.GestureListener>
</TextBlock>

以及事件处理程序的以下内容:

private void TapAndHold(object sender, GestureEventArgs e)
{
    this.ApplicationBar.IsVisible = !this.ApplicationBar.IsVisible;
}

然后按住文本块上的任何位置将切换ApplicationBar的显示。

如果您希望切换,如果用户点击并保持在页面上的任何位置,那么您可以将手势监听器附加到页面的根对象。 e.g。

<Grid x:Name="LayoutRoot" Background="Transparent">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <toolkit:GestureService.GestureListener>
        <toolkit:GestureListener Hold="TapAndHold" />
    </toolkit:GestureService.GestureListener>

答案 1 :(得分:1)

使用当前页面的ApplicationBar属性并相应地切换IsVisible属性以显示/隐藏ApplicationBar。 ApplicationBar由操作系统处理,因此将为您处理显示和隐藏它的动画。

相关问题