[UWP][C#]How to change background color of navigation view frame top title area

kranthi kumar 206 Reputation points
2023-02-17T17:05:08.93+00:00

i am trying to change background color of top section of frame in a navigation view (winUI2) but couldn't find any property to do so, please see attached image below, is there a way to change that color or remove it ?colorChange

Universal Windows Platform (UWP)
XAML
XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
832 questions
0 comments No comments
{count} votes

Accepted answer
  1. Roy Li - MSFT 34,101 Reputation points Microsoft External Staff
    2023-02-20T03:05:09.9466667+00:00

    Hello,

    Welcome to Microsoft Q&A!

    Based on the image you shared, the area is the Title bar of the UWP app. It is not a part of the NavigationView. If you want to change the color of the Title bar, you could get the system Title bar by calling ApplicationView.GetForCurrentView().TitleBar.Then you could change the color of the Title bar like background color, foreground color, button color, etc.

    Here is the code I use:

    
     public MainPage()
            {
                this.InitializeComponent();
    
    
                var titleBar = ApplicationView.GetForCurrentView().TitleBar;
    
                // Set active window colors
                titleBar.ForegroundColor = Colors.White;
                titleBar.BackgroundColor = Colors.Green;
                titleBar.ButtonForegroundColor = Colors.White;
                titleBar.ButtonBackgroundColor = Colors.SeaGreen;
                titleBar.ButtonHoverForegroundColor = Colors.White;
                titleBar.ButtonHoverBackgroundColor = Colors.DarkSeaGreen;
                titleBar.ButtonPressedForegroundColor = Colors.Gray;
                titleBar.ButtonPressedBackgroundColor = Colors.LightGreen;
    
                // Set inactive window colors
                titleBar.InactiveForegroundColor = Colors.Gainsboro;
                titleBar.InactiveBackgroundColor = Colors.SeaGreen;
                titleBar.ButtonInactiveForegroundColor = Colors.Gainsboro;
                titleBar.ButtonInactiveBackgroundColor = Colors.SeaGreen;
            }
    
    

    This is the result:

    User's image

    Thank you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. kranthi kumar 206 Reputation points
    2023-02-20T08:09:45.7033333+00:00

    Thanks for the reply, the color issue is due to previous version of app installed which is using title bar color as you mentioned, after uninstalling & running app fresh the issue is resolved.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.