Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 296
Raj Rao Avatar asked Mar 11 '26 00:03

Raj Rao


2 Answers

You can use the GestureService in the toolkit to detect the Hold event.

For example.
If you had this xaml on a page:

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

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. 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>
like image 123
Matt Lacey Avatar answered Mar 13 '26 01:03

Matt Lacey


Use the ApplicationBar property of the current page and toggle the IsVisible property accordingly to show/hide the ApplicationBar. The ApplicationBar is handled by the operating system, so the animation for showing and hiding it will be handled for you.

like image 29
Derek Lakin Avatar answered Mar 13 '26 01:03

Derek Lakin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!