2011-01-14 93 views
3

在许多Windows Phone 7应用程序中,应用程序栏默认为隐藏状态,当您按住屏幕上的按钮时,应用程序栏将变为可见。由于许多WP7应用程序都有这种行为,所以我想知道,是否有与ApplicationBar的这种行为的内置支持,以及如何使用它?WP7 - show hide应用程序栏

+0

可能重复的[Windows Phone 7的隐藏应用程序栏(http://stackoverflow.com/questions/4116311/windows-phone-7-hiding-the-application-bar) – 2011-01-14 06:13:28

回答

6

您可以使用toolkit中的手势服务来检测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; 
} 

然后按住该文本块的任何地方将切换应用程序任务栏的显示。

如果您希望切换用户在页面上的任意位置轻敲并保持,则可以将手势监听器附加到页面的根对象。例如

<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

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