greg
greg

Reputation: 1204

Windows 10 mobile, change status bar color

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

I attempted the above method, but I am getting this error: https://msdn.microsoft.com/en-us/library/ms228508.aspx

** Edit ** Found the issue, 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 It's a matter of adding the "Microsoft Mobile Extension SDK for Universal App Platform" extension to the C# project references.

Upvotes: 1

Views: 2189

Answers (1)

Vineet Choudhary
Vineet Choudhary

Reputation: 7631

Add the refernce of Microsoft Mobile Extension SDK for Universal App Platform in your project. You can find it under Reference Manager -> 1. Windows Universal -> 2. Extensions.

enter image description here

You can change TitleBar for Windows and the StatusBar for Mobile like that:

//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;
}

Hope this is helpful to someone.

Reference - Change title bar and status bar color on WUP

Upvotes: 5

Related Questions