Windows 10移动,更改状态栏颜色

gre*_*reg 1 windows-10 windows-10-mobile

Windows.UI.ViewManagement.StatusBar.GetForCurrentView().ForegroundColor = Colors.White;
Run Code Online (Sandbox Code Playgroud)

我尝试了上面的方法,但是我收到了这个错误: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-on-pcs?forum = wpdevelop 这是为C#项目引用添加"Microsoft Mobile Extension SDK for Universal App Platform"扩展的问题.

Vin*_*ary 5

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

在此输入图像描述

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

//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;
}
Run Code Online (Sandbox Code Playgroud)

希望这对某人有帮助.

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