How can i hide Navigation Bar? c++ UWP

Оля Щербина 1 Reputation point
2022-09-12T09:36:06.3+00:00

Hi,
I have created UWP project(for universal apps c++). I had a problem with Navigation Bar, I cannot hide it. Early, I use UPF for c# there hide this bar is very simple. Needed only write WindowStyle="None" but how can I do this in UWP project?

my code:
<Page
x:Class="App1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App1"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background = "#393E46">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="50"/>
</Grid.ColumnDefinitions>
</Grid>
</Page>

Universal Windows Platform (UWP)
{count} votes

1 answer

Sort by: Most helpful
  1. Roy Li - MSFT 31,786 Reputation points Microsoft Vendor
    2022-09-13T03:22:15.987+00:00

    Hello,

    Welcome to Microsoft Q&A!

    How can i hide Navigation Bar?

    I checked the code, there is no Navigation bar in your app. It seems that you are trying to hide Title bar, right?

    The first thing is to hide the default title bar and extend your content into the title bar area. What you need to do is set the CoreApplicationViewTitleBar.ExtendViewIntoTitleBar property that extends app content into the title bar area to true.

    System caption buttons(minimize, maximize/restore, close) can't be hidden, but you could change the look of the system caption buttons and make them to be transparent by setting some of the color properties of the ApplicationViewTitleBar(the default title bar)

    I'm not sure if you are using C++/CX or C++/WinRT.

    Here is the code for C++/CX:

       using namespace Windows::UI::ViewManagement;  
    using namespace Windows::UI;  
    using namespace Windows::ApplicationModel::Core;  
    
    auto  _coreTitleBar = CoreApplication::GetCurrentView()->TitleBar;  
    _coreTitleBar->ExtendViewIntoTitleBar = true;  
    
    auto _TitleBar = ApplicationView::GetForCurrentView()->TitleBar;  
    
    _TitleBar->ButtonBackgroundColor = Colors::Transparent;  
    _TitleBar->ButtonInactiveBackgroundColor = Colors::Transparent;  
    _TitleBar->ButtonPressedBackgroundColor = Colors::Transparent;  
    _TitleBar->ButtonHoverBackgroundColor = Colors::Transparent;  
    

    For more information, you could take a look at this document: Title bar customization. And sample here: Title bar sample

    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