1
Windows.UI.ViewManagement.StatusBar.GetForCurrentView().ForegroundColor = Colors.White;

我尝试了上述方法,但出现此错误: https ://msdn.microsoft.com/en-us/library/ms228508.aspx

** 编辑 ** 发现问题,https://social.msdn.microsoft.com/Forums/windowsapps/en-US/317ed159-75e3-4f8d-a8b7-2e70a5c68bfb/uwp10-how-to-change-statusbar-color -on-phone-and-the-title-bar-on-pcs?forum=wpdevelop 将“Microsoft Mobile Extension SDK for Universal App Platform”扩展添加到 C# 项目引用中。

4

1 回答 1

5

Microsoft Mobile Extension SDK for Universal App Platform在您的项目中添加引用。您可以在 Reference Manager -> 1. Windows Universal -> 2. Extensions 下找到它。

在此处输入图像描述

您可以像这样更改 Windows 的 TitleBar 和 Mobile 的 StatusBar:

//windows title bar      
Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().TitleBar.BackgroundColor = Color.FromArgb(100,230, 74, 25);
Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().TitleBar.ForegroundColor = Colors.White;
Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().TitleBar.ButtonBackgroundColor = Color.FromArgb(100, 230, 74, 25);
Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().TitleBar.ButtonForegroundColor = Colors.White;

//StatusBar for Mobile

if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
{
    Windows.UI.ViewManagement.StatusBar.GetForCurrentView().BackgroundColor = Color.FromArgb(100, 230, 74, 25);
    Windows.UI.ViewManagement.StatusBar.GetForCurrentView().BackgroundOpacity = 1;
    Windows.UI.ViewManagement.StatusBar.GetForCurrentView().ForegroundColor = Colors.White;
}

希望这对某人有帮助。

参考 -在 WUP 上更改标题栏和状态栏颜色

于 2016-03-08T19:59:03.107 回答