Search code examples
windows-10uwpwindows-10-mobile

Hide status bar in UWP


I have used below code to hide status bar in UWP. When I run the app in development mode in my computer the status bar is not shown in windows phone. I deployed the app in Windows Store, after downloading the app, I see the status bar appears in my app.

Here is my code:

var isAvailable = Windows.Foundation.Metadata.ApiInformation.IsTypePresent(typeof(StatusBar).ToString());
   if (isAvailable)
       hideBar();

async void hideBar()
{
   StatusBar bar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView();
   await bar.HideAsync();
}

The question is, why the above code shouldn't work in windows store? Also, I have the link to my app App link in windows store, but when i search for exact key word in windows store, my application is not shown in windows store, but clicking in link would appear my app in window store.

Thanks!


Solution

  • Checking for the Contract, rather for the type StatusBar works fine for me.

    private async Task InitializeUi()
    {
        // If we have a phone contract, hide the status bar
        if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1, 0))
        {
            var statusBar = StatusBar.GetForCurrentView();
            await statusBar.HideAsync();
        }
    }