WP7 - 显示隐藏应用程序栏

Raj*_*Rao 3 windows-phone-7

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

Mat*_*cey 6

您可以使用工具包中的GestureService 来检测Hold事件.

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

<TextBlock TextWrapping="Wrap" Text="lorem ipsum ...">
    <toolkit:GestureService.GestureListener>
        <toolkit:GestureListener Hold="TapAndHold" />
    </toolkit:GestureService.GestureListener>
</TextBlock>
Run Code Online (Sandbox Code Playgroud)

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

private void TapAndHold(object sender, GestureEventArgs e)
{
    this.ApplicationBar.IsVisible = !this.ApplicationBar.IsVisible;
}
Run Code Online (Sandbox Code Playgroud)

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

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

<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>
Run Code Online (Sandbox Code Playgroud)