Hide status bar in UWP

I used the code below to hide the status bar in UWP. When I run the application in development mode on my computer, the status bar does not appear on the Windows phone. I deployed the application in the Windows Store, after loading the application, I see that the status bar is displayed in my application.

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 should the above code not work in the Windows store? In addition, I have a link to my application, a link to the application in the Windows repository, but when I search for the exact keyword in the windows of the repository, my application does not appear in the Windows repository, but when I click on the link my application in the window repository will appear.

Thanks!

+7
windows-10 uwp windows-10-mobile
source share
5 answers

Check for Contract , but for type StatusBar great 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(); } } 
+10
source share

Maybe when you compile in Release and using the .NET native toolchain, the type information is discarded and therefore you are not passing the string you think you are passing? Maybe you can try hard coding the full type name?

+1
source share

This code will not work, because after .Net Native compilation (which stores) typeof (StatusBar). ToString () will not return the literal type name as you expect, but will return something like "EETypeRVA: 0x00021968". Use a literal string instead (you're not going to rename the StatusBar, right ?;) Or use IsApiContractPresent or typeof (StatusBar). FullName (as already mentioned). Postscript The same problem can be reproduced without publishing, just run it using the Release configuration.

+1
source share

You should use FullName instead of ToString() :

 ... ApiInformation.IsTypePresent(typeof(StatusBar).FullName); ... 
0
source share

In Windows 10, the Window.Current.SetTitleBar command (zero);

0
source share

All Articles