using System.Collections.Generic; using System.Windows.Controls; public static class NavigationHelper { public static Frame MainFrame { get; set; } private static Stack _history = new Stack(); // 跳转页面 public static void NavigateTo(Page page) { if (MainFrame.Content != null) _history.Push( MainFrame.Content as Page); MainFrame.Content = page; } // 返回上一页 public static void GoBack() { System.Diagnostics.Debug.WriteLine("页面加载了!55555"); if (_history.Count > 0) { System.Diagnostics.Debug.WriteLine("页面加载了!4444"); MainFrame.Content = _history.Pop(); } } }