简体   繁体   English

WP7 - 显示隐藏应用程序栏

[英]WP7 - show hide application bar

In many of the Windows Phone 7 apps, the application bar is hidden by default and when you press and hold down on the screen, the application bar is made visible. 在许多Windows Phone 7应用程序中,默认情况下隐藏应用程序栏,当您按住屏幕时,应用程序栏会显示。 As many of the WP7 apps have this behavior, I was wondering, if there was in-built support for this kind of behavior with the ApplicationBar and how do I go about using it? 由于许多WP7应用程序都有这种行为,我想知道,如果使用ApplicationBar有这种行为的内置支持,我该如何使用它呢?

You can use the GestureService in the toolkit to detect the Hold event. 您可以使用工具包中的GestureService来检测Hold事件。

For example. 例如。
If you had this xaml on a page: 如果你在页面上有这个xaml:

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

and the following for the event handler: 以及事件处理程序的以下内容:

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

then holding down any where on the textblock would toggle the display of the ApplicationBar. 然后按住文本块上的任何位置将切换ApplicationBar的显示。

If you wanted the toggling if the user tapped and held anywhere on the page then you could attach the gesture listener to the root object of the page. 如果您想要切换,如果用户点击并保持在页面上的任何位置,那么您可以将手势监听器附加到页面的根对象。 eg 例如

<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>

Use the ApplicationBar property of the current page and toggle the IsVisible property accordingly to show/hide the ApplicationBar. 使用当前页面的ApplicationBar属性并相应地切换IsVisible属性以显示/隐藏ApplicationBar。 The ApplicationBar is handled by the operating system, so the animation for showing and hiding it will be handled for you. ApplicationBar由操作系统处理,因此将为您处理显示和隐藏它的动画。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM