Retrieve WP system tray (notification area) height

488 views Asked by At

For some control layout calculations, I need to know the height of the notification area. Sure, I know that it equals 32 pixels in portrait mode in WP 7/8/8.1, but it's not a good idea to hard code this value for the future releases of the OS. How can I retrieve this value on-the-fly in a Silverlight app?

3

There are 3 answers

1
TecMan On BEST ANSWER

Found a workaround. We can determine the vertical offset for the main layout root control (generally a Grid), and it will be the height of the system tray:

private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
    GeneralTransform gt = LayoutRoot.TransformToVisual(Application.Current.RootVisual as UIElement);
    Point offset = gt.Transform(new Point(0, 0));
    double systemTrayHeight = offset.Y;
}
1
Amit Bhatiya On

You cant get Height of notification area by Code.

its Standards are Pre-Defined. System Tray is the small tiny bar across the top of the Phone screen. It displays in Portrait mode. When your application is set in Portrait mode, the height of the System Tray becomes 32 pixel and when the application is set in Landscape mode, the width of the System Tray becomes 72 pixel. This is as per the UI Design Guidelines and Interaction Guideline of Windows Phone 7.

You can get more information here about what is accessible

4
RandomEngy On
double contentScaleFactor = (double)Application.Current.Host.Content.ScaleFactor / 100;
double systemTrayHeight = 32 / contentScaleFactor;

Or 72 for landscape orientation. Phones like the Lumia 1520 scale the app content up, so you have to adjust for it.