Reputation: 15
Is it possible to hide the status bar on screen rotation events in Windows Phone 8.1
?
Upvotes: 1
Views: 218
Reputation: 3324
The following code shows the status bar on Portrait
orientation, and hides it on Landscape
orientation.
First you need to subscribe to the ApplicationView.VisibleBoundsChanged
event. You can do this for example in your App.xaml.cs
constructor:
ApplicationView.GetForCurrentView().VisibleBoundsChanged += OnVisibleBoundsChanged;
You hide the status bar with the StatusBar.GetForCurrentView()
instance.
OnVisibleBoundsChanged method:
private async void OnVisibleBoundsChanged(ApplicationView sender, object args)
{
var currentView = ApplicationView.GetForCurrentView();
if (currentView.Orientation == ApplicationViewOrientation.Portrait)
{
await StatusBar.GetForCurrentView().ShowAsync();
}
else if (currentView.Orientation == ApplicationViewOrientation.Landscape)
{
await StatusBar.GetForCurrentView().HideAsync();
}
}
Upvotes: 1