I am looking to change the colors of the title bar to better suit my app similar to what has been done in the Mail app. How would I go about doing that?
3 Answers
The background and foreground colors of parts of the TitleBar can be changed as follows.
ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar;
titleBar.BackgroundColor = Colors.Black;
titleBar.ForegroundColor = Colors.White;
titleBar.ButtonBackgroundColor = Colors.Black;
titleBar.ButtonForegroundColor = Colors.White;
Be aware that these changes happen after the app has displayed so the user will see the colors change.
-
It doesn't seem to be changing the color of the status bar on Windows 10 mobile. Do I have to do something different for that? Aug 17, 2015 at 6:07
-
2Not sure if still needed, but when you want to change the color of the statusbar, you'll need to add extra code. First see if you are on a Mobile family :
if(Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Mobile")
After that, grab the statusbar and set the ForegroundColor and BackgroundColo– DepechieAug 18, 2015 at 8:42 -
4@Depechie Do not inspect the DeviceFamily; that is analytics information, not for programmatic decisions. To see if the status bar API is available (note: Status bar may be present on devices other than Mobile), use
Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")
. Sep 23, 2015 at 5:08 -
@RaymondChen true... wasn't aware of that API info key until recently :)– DepechieSep 23, 2015 at 6:50
You can customize the background of the title bar by doing the following:
var appView = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();
var titleBar = appView.TitleBar;
titleBar.BackgroundColor = Colors.Black;
You can change the other colors of the title bar like the foreground color or the button colors by changing the color in the other properties.
You can customize the buttons and title text by adding a extend view into the title bar. please find the code snippet for this.
private void ExtendViewOftitleBar()
{
CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
ApplicationView view = ApplicationView.GetForCurrentView();
ApplicationViewTitleBar titleBar = view.TitleBar;
view.SuppressSystemOverlays = true;
titleBar.BackgroundColor = Windows.UI.Color.FromArgb(0, 0, 0, 0);
titleBar.ForegroundColor = Windows.UI.Color.FromArgb(0, 0, 0, 0);
titleBar.InactiveBackgroundColor = Windows.UI.Color.FromArgb(0, 0, 0, 0);
titleBar.InactiveForegroundColor = Windows.UI.Color.FromArgb(0, 0, 0, 0);
titleBar.ButtonBackgroundColor = Windows.UI.Color.FromArgb(0, 0, 0, 0);
titleBar.ButtonHoverBackgroundColor = Windows.UI.Color.FromArgb(0, 0, 0, 0);
titleBar.ButtonPressedBackgroundColor = Windows.UI.Color.FromArgb(0, 0, 0, 0);
titleBar.ButtonInactiveBackgroundColor = Windows.UI.Color.FromArgb(0, 0, 0, 0);
}