从 WPF Pages 应用程序中删除导航栏

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32397623/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 13:23:15  来源:igfitidea点击:

Remove navigation bar from WPF Pages application

c#wpfxaml

提问by TheUnexpected

I have a WPF/XAML Window that navigates different Pages. The navigation is performed this way:

我有一个导航不同页面的 WPF/XAML 窗口。导航是这样执行的:

MainFrame.Navigate(new LoginPage(this));

The problem is that, at the first navigation, a bar appears on top of the Window:

问题是,在第一次导航时,窗口顶部会出现一个栏:

enter image description here

在此处输入图片说明

How can I remove/hide it?

如何删除/隐藏它?

回答by sbouaked

Step 1. In your Frame Tag Add the Event ContentRendered. as

步骤 1. 在您的 Frame 标签中添加事件 ContentRendered。作为

 <Frame Name="myFrame" ContentRendered="myFrame_ContentRendered" ></Frame>

Step 2. In the ContentRendered event handler set the NavigationUIVisibility Hidden for each page instead on calling the same on all the pages as.

步骤 2. 在 ContentRendered 事件处理程序中,为每个页面设置 NavigationUIVisibility Hidden,而不是在所有页面上调用相同的方法。

     private void myFrame_ContentRendered(object sender, EventArgs e)
    {
        myFrame.NavigationUIVisibility = System.Windows.Navigation.NavigationUIVisibility.Hidden;
    }

or simply use : <Frame Source="YOURPAGE.xaml" NavigationUIVisibility="Hidden" />

或者干脆使用: <Frame Source="YOURPAGE.xaml" NavigationUIVisibility="Hidden" />

回答by Jason Min

If you use the Navigation window, Please use it.

如果您使用导航窗口,请使用它。

ShowsNavigationUI="False"

ShowsNavigationUI="False"