Wednesday, August 5, 2015

Windows Phone disable status bar

Problem:
Trying to fix a problem on a Windows Phone Silverlight 8.1 app today.  The app starts with a splash screen and do to some extra processing it has an extended screen which simply displays the same screen again.  The issue arises when the splash screen which the OS handles switches over to the first view which also displays the same splash screen image.  Due to the status bar displaying on the first screen the image shifts down.  This leads the image dropping down vice staying in place.  The transition from needs to be smooth without any resizing of the image.  The solution seems to be simply to hide the status bar on that screen.  But how to do it?

Solution:

Windows Phone 8 / Windows Phone 8/8.1 Silverlight


Code behind in ExtendedSplashScreenView.xaml.cs:

public partial class ExtendedSplashScreenView(): MvxPhonePage
{
  InitializeComponent();
  Loaded += MainPage_Loaded;
}

private void MainPage_Loaded(object sender, RoutedEventArgs events)
{
  SystemTray.IsVisible = false;
}


Windows Phone 8.1

Code behind in ExtendedSplashScreenView.xaml.cs:

public partial class ExtendedSplashScreenView(): MvxPhonePage

{
  // Get the Status bar for the Current Window.
  Windows.UI.ViewManagement.StatusBar statusBar =     Windows.UI.ViewManagement.StatusBar.GetForCurrentView();
  // Hides the status bar
  await statusBar.HideAsync();
}


Source:
1.) Windows Phone 8 / Silverlight
  • http://stackoverflow.com/questions/6674627/how-to-hide-the-status-bar-in-wp7-silverlight
2.) Windows Phone 8.1
  • http://blogs.msdn.com/b/johnkenn/archive/2014/04/16/hiding-the-status-bar-in-windows-phone-8-1-apps-or-not.aspx
  •  http://developerpublish.com/how-to-hide-status-bar-in-windows-phone-8-1-xaml-app/
  •  http://blogs.msdn.com/b/amar/archive/2014/05/12/status-bar-in-windows-phone-8-1.aspx

No comments:

Post a Comment