我对Windows通用应用程序很新,几天前我开始设计我的第一个应用程序,并且在任务栏中设置白色图标时出现问题。在Windows 8.1中它很容易,但无论我为主题,电池,时钟设置什么......总是很暗。 有谁知道如何改变颜色?
由于
答案 0 :(得分:3)
虽然您接受的答案是正确的,并且您需要延期,但最好不要'不是'检查设备系列。因为它可能会在未来改变,其他设备也可以拥有状态栏!所以用它来验证一个是否可用:
if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) { ... }
答案 1 :(得分:1)
使用
var statusBar = StatusBar.GetForCurrentView();
然后设置 ForegroundColor 。
statusBar.ForegroundColor = Colors.White;
可悲的是,如果没有其他代码,就无法再从Xaml完成。
答案 2 :(得分:-1)
您希望编写仅在特定设备系列上运行的代码,例如Windows Mobile。为此,请为UWP添加 Window Mobile Extensions 。
如上所述,您可以在App.xaml.cs中添加代码。它是oke,但我建议先检查将使用哪个平台。
这是一个小片段:
private void InitializeThemes()
{
switch (AnalyticsInfo.VersionInfo.DeviceFamily)
{
case "Windows.Mobile":
StatusBar statusBar = StatusBar.GetForCurrentView();
break;
case "Windows.Desktop":
ApplicationView applicationView = ApplicationView.GetForCurrentView();
break;
}
}
如评论中所述,上述解决方案并不适合您的情况。而是使用@Depechie回答中描述的方法。