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

时间:2015-08-26 07:03:53

标签: windows-10 windows-10-mobile

media="screen"

我尝试了上面的方法,但是我收到了这个错误: 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#项目引用的问题。

1 个答案:

答案 0 :(得分:5)

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

enter image description here

您可以像这样更改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;
}

希望这对某人有帮助。

参考 - Change title bar and status bar color on WUP