UWP的TitleBar后退按钮

Fre*_*gar 15 .net c# windows titlebar win-universal-app

我已经看到Windows设置正在使用标题栏中的后退按钮 ; 并希望在我的UAP中包含类似的内容,但由于Win10很新,如果可以通过简单的方式实现,我找不到任何信息.

非常感谢

Her*_*rdo 29

您可以像这样轻松激活后退按钮:

using Windows.UI.Core;

var currentView = SystemNavigationManager.GetForCurrentView();
currentView.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
Run Code Online (Sandbox Code Playgroud)

请注意,BackRequested在同一视图中使用事件处理后退事件:

currentView.BackRequested += // Event handler goes here
Run Code Online (Sandbox Code Playgroud)

请注意:当应用程序在桌面模式下运行时,后退按钮仅显示在标题栏中.当应用程序以平板电脑模式运行时,后退按钮将移至Windows任务栏(左下角).

  • 如果你想在项目的任何地方处理它.在App.xaml.cs中使用它,如[here]所示(http://www.wintellect.com/devcenter/jprosise/handling-the-back-button-in-windows-10-uwp-apps) (3认同)

Map*_*oft 6

尽管建议的答案仍然适用于Win10 1803,但随着1709的发布,微软开始不鼓励使用AppViewBackButton来支持应用程序后退按钮.这是一些XAML:

<Button VerticalAlignment="Top" HorizontalAlignment="Left" 
Style="{StaticResource NavigationBackButtonNormalStyle}"/>
Run Code Online (Sandbox Code Playgroud)

阅读更多:https: //docs.microsoft.com/en-us/windows/uwp/design/basics/navigation-history-and-backwards-navigation