Windows 10 Mobile - 无法隐藏状态栏(上下文中不存在StatusBar)

时间:2015-07-23 17:47:04

标签: windows statusbar

我正在尝试隐藏Windows 10 Universal App中的状态栏。在WP 8.1中,我使用<link rel="shortcut icon" href="http://i.imgur.com/Bj3KBRt.png" type="image/x-icon" /> <title>Welcome to Wumbo's Site</title> <body background="http://i.imgur.com/hySVC7M.png"> <div id="center"> <center> <h1><font face="trebuchet MS" color="dbdbdb">This Site is Under Construction!</h1> <p>In a few months, when I am finished, I will unveil this site! In the meantime, also for updates, follow me on twitter. <br> I also have a Youtube channel where I upload stupid crap!</p> <br> <h1>MY SOCIAL NETWORKZ</h1> <a href="https://twitter.com/BullCloaker">Twitter</a> <br> <a href="https://youtube.com/user/calluvdutyplayr9"> My Youtube Channel</a> <p> I'm not sure what I'm going to do with this site, <br> But it will most likely be a portfolio, where I share all the drawings, <br> animations and other such things I've made. <br> Seeya! <br> <font face="trebuchet MS" color="#00ffaa"> ~Wumbo ( &#865;&#176; &#860;&#662; &#865;&#176;)</font> </font> <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br<br><br><br><br><br><br><br><br><br><br><br><br><br><br> <font face="Arial" color="#00ffaa" size="1">You are currently using the Dark Site Skin.<a href="file:///C:/Users/jeanpaul/Desktop/Websites/SiteLight.html">Click Here to use the Light Site Skin</a> <br> <br> <br> <a href="file:///C:/Users/jeanpaul/Desktop/Websites/AboutPageDark.html">About</a> &#8226; <a href="https://google.com">Gallery</a> &#8226; <a href="https://google.com">Videos</a> &#8226; <a href="file:///C:/Users/jeanpaul/Desktop/websites/SiteDark.html">Main</a> </center> </div>来隐藏状态栏,但是这在我当前的项目中不起作用(Monogame,Win10 UAP) - 我在当前上下文中找不到“StatusBar”错误(是的,我正在使用Windows.UI.ViewManagement)。 我做错了什么,或者这个删除StatusBar的选项被删除了吗?我应该如何在W10M中完成这项工作? 提前谢谢。

1 个答案:

答案 0 :(得分:21)

诀窍是您必须首先添加对Microsoft Mobile Extension SDK的引用。 然后代码如下:

StatusBar statusBar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView();
await statusBar.HideAsync();

可以通过右键单击通用项目来添加引用。选择&#34;添加参考&#34;。在Reference Manager对话框中选择&#34; Windows Universal&#34;在左边。选择&#34;扩展程序&#34;并检查&#34; Microsoft Mobile Extension SDK ...&#34;。

Select the Extension SDK in the Reference Manager

由于这是一个通用应用程序,它将在每个设备上运行,但API仅在Windows 10的移动设备(也称为电话)上可用。因此,在实际调用之前,如果此API在运行时可用,则进行功能检测API。否则它将在运行时抛出TypeLoadException。

使用Windows.Foundation.Metadata.ApiInformation命名空间查看API是否可用。 (例如,方法IsTypePresent()。 我建议在这里使用typeof而不是Strings,例如像这样:

var isStatusBarPresent = ApiInformation.IsTypePresent(typeof(StatusBar).ToString());

在此处详细了解自适应代码:https://channel9.msdn.com/Series/A-Developers-Guide-to-Windows-10/08