TitleBar back button for UWP

眉间皱痕 提交于 2019-11-29 06:37:51

问题


I've seen that the windows settings are using a back button in the title bar; and would like to include something like that in my UAP but since Win10 is pretty new I couldn't find any information if this is achievable in a simple way.

Thanks very much


回答1:


You can activate the back button easily like this:

using Windows.UI.Core;

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

Please note, that the back event is handled with the BackRequested event on the same view:

currentView.BackRequested += // Event handler goes here

Please note: The back button is only displayed in the title bar, when the app is running in desktop mode. When the app is running in tablet mode, the back button is moved to the Windows task bar (bottom left).




回答2:


Although the suggested answer still works as of Win10 1803, with the release of 1709 Microsoft began discouraging the use of AppViewBackButton in favor of an in-app back button. Here's some XAML:

<Button VerticalAlignment="Top" HorizontalAlignment="Left" 
Style="{StaticResource NavigationBackButtonNormalStyle}"/>

Read more: https://docs.microsoft.com/en-us/windows/uwp/design/basics/navigation-history-and-backwards-navigation



来源:https://stackoverflow.com/questions/31693314/titlebar-back-button-for-uwp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!