简体   繁体   中英

UWP NavigationView not lining up with titlebar back button

I'm trying to line up my NavigationView with the back button that comes built into the window like so:

[ 一字排开的酒吧 ]

but when i try to line up my NavigationView it ends up looking like

[ 这个 ]

How should i go about changing the width of the NavigationView so that it lines up with the back button?

The reason why the back button isn't aligned for you is that you're using the embedded back button in the title bar, which is deprecated now (as in, the MS guidelines suggest not to use it anymore, and to replace it with a dedicated back button in the app UI).

What you want to do is to set the IsBackButtonVisible property of the NavigationView to Visible , and use that back button instead to handle the navigation in your frame, or in other parts of your app.

To handle the back navigation request, you can just register to the BackRequested event in the NavigationView control.

Also, to hide the back button in the title bar, you just need to remove these couple lines in your code:

var currentView = SystemNavigationManager.GetForCurrentView();
currentView.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM