1.在OnNavigateTo 裡,設定是否顯示Back Button
SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = frame.CanGoBack ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed;
2. 註冊BackRequested事件
SystemNavigationManager.GetForCurrentView().BackRequested += View_BackRequested
C#:
public static class NavigationManager { static NavigationManager() { SystemNavigationManager.GetForCurrentView().BackRequested += View_BackRequested; } private static void View_BackRequested(object sender, BackRequestedEventArgs e) { var frame = Window.Current.Content as Frame; if (frame == null) { return; } if (!frame.CanGoBack) { return; } if (e.Handled) { return; } e.Handled = true; frame.GoBack(); } public static void ShowBackButtonIfNeeded() { var frame = Window.Current.Content as Frame; if (frame == null) { return; } SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = frame.CanGoBack ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed; } }
參考資料:
http://stackoverflow.com/questions/30597585/windows-10-uap-back-button
https://msdn.microsoft.com/zh-tw/library/windows/apps/mt465734.aspx
全站熱搜
留言列表