How to change the title bar’s color in a UWP app

Posted by Blake on 1/31/2017

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.


    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;