How to change the title bar color in a UWP app


The following is a snippet that will allow you to programatically change the background and foreground color of the title bar in a Windows Store app from a code behind. In this case, I will be setting the bar to a dark gray color similiar to what is found in Visual Studio's dark color scheme. I typically put this code in the Loaded event of my main page but it also works fine from the loaded event in App.xaml.cs.

C#

if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.ApplicationView"))
{
    var titleBar = ApplicationView.GetForCurrentView().TitleBar;

    if (titleBar != null)
    {
        titleBar.ButtonBackgroundColor = Color.FromArgb(255, 30, 30, 30);
        titleBar.ButtonForegroundColor = Colors.White;
        titleBar.BackgroundColor = Color.FromArgb(255, 30, 30, 30);
        titleBar.ForegroundColor = Colors.White;
    }
}

Leave a comment

Please note that we won't show your email to others, or use it for sending unwanted emails. We will only use it to render your Gravatar image and to validate you as a real person.