0

I have this kind of code in my app to hide the SystemTray, and i cant do this same for the Applicationbar. Why? I want to change the isVisible property on rotation change.

This is the code:

private void PhoneApplicationPage_BeginLayoutChanged(object sender, OrientationChangedEventArgs e)
    {
        if (e.Orientation == PageOrientation.PortraitUp)
        {
            AppBar.IsVisible = true;
            SystemTray.IsVisible = true;
        }
        else
        {
            AppBar.IsVisible = false;
            SystemTray.IsVisible = false;
        }
    }

I named the applicationbar to AppBar but i cant change this property, i tried to look whats wrong and on debugging i see the value for AppBar is null, why?

Is there any other method so i can hide it on roation change?! Am i doing something wrong? Because this method wroks for hiding the SystemTray

dinchy87
  • 169
  • 1
  • 12

2 Answers2

3

Let's just be nice and say that ApplicationBar is a funny little creature :) Have you tried accessing it on your page this way?

this.ApplicationBar.IsVisible = true;
Igor Ralic
  • 14,975
  • 4
  • 43
  • 51
  • Thats it. :) thank you :) i did not know that i can not "name" the application bar via x:name and access it then in code... That solved my issue. :) – dinchy87 Feb 27 '14 at 17:10
0

Have you tried?

private void PhoneApplicationPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
{
    // PageOrientation.PortraitDown is never used
    if (e.Orientation == PageOrientation.PortraitUp ||
        e.Orientation == PageOrientation.Portrait) 
    {
        AppBar.IsVisible = true;
        SystemTray.IsVisible = true;
    }
    else
    {
        AppBar.IsVisible = false;
        SystemTray.IsVisible = false;
    }
}
Pantelis
  • 2,060
  • 3
  • 25
  • 40