Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 428
ARH Avatar asked Dec 16 '15 05:12

ARH


3 Answers

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();
    }
}
like image 144
Herdo Avatar answered Nov 01 '22 02:11

Herdo


You have to use FullName instead of ToString():

...
ApiInformation.IsTypePresent(typeof(StatusBar).FullName);
...
like image 2
Vitali Avatar answered Nov 01 '22 00:11

Vitali


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.

like image 2
sich Avatar answered Nov 01 '22 02:11

sich