7
votes

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!

5

5 Answers

10
votes

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();
    }
}
2
votes

You have to use FullName instead of ToString():

...
ApiInformation.IsTypePresent(typeof(StatusBar).FullName);
...
2
votes

This code won't work because after .Net Native compilation (which Store does) typeof(StatusBar).ToString() will not return the literal type name as you expect, but will return something like "EETypeRVA:0x00021968". Use literal string instead (you aren't going to rename StatusBar, right? ;) or use IsApiContractPresent or typeof(StatusBar).FullName (as was already advised). P.S. The same issue can be reproduced without publishing, just run it using Release configuration.

1
votes

Could it be that when you compile in Release and with the .NET Native toolchain, the type info gets discarded and so you're not passing the string you think you're passing? Maybe you can try hard-coding the full type name?

0
votes

In Windows 10 the command is Window.Current.SetTitleBar(null);