UWP: Set status bar to remove empty white space on top in Mobile Emulator

Problem:
– Having empty white space on top of Windows 10 Mobile Emulator

StatusBar
Cause:
– The status bar is not set correctly
Solution:
– Set background color for the status bar
– Hide the status bar if needed
Set the code below in App.cs OnLaunched
Code:

//Set Status bar
if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
{
	var statusBar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView();
	statusBar.BackgroundColor = Windows.UI.Colors.Green;
	statusBar.BackgroundOpacity = 1;
	await statusBar.HideAsync();
}

Note:
You must add reference to Extensions | Windows Mobile Extensions for the UWP

StatusBarAfter

Leave a Reply