protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); var frame = new TestFrame { Source = new Uri("MainPage.xaml", UriKind.Relative), }; var window = new Window { Content = frame, WindowState = WindowState.Maximized, UseLayoutRounding = true }; window.SetBinding(TitleBar.IsBackButtonVisibleProperty, new Binding("CanGoBack") { Source = frame }); TitleBar.AddBackRequestedHandler(window, delegate { frame.GoBack(); }); MainWindow = window; _isRootCreated = true; window.Show(); }
public NavigationService(Window window, NavigationView navigationView, Frame frame) { this.navigationView = navigationView; this.frame = frame; this.navigationView.ItemInvoked += OnItemInvoked; BackRequestedEventHandler += OnBackRequested; TitleBar.AddBackRequestedHandler(window, BackRequestedEventHandler); }
public NavigationService(Window window, NavigationView navigationView, Frame frame) { if (Current == null) { Current = this; } else { throw new InvalidOperationException("NavigationService的实例在运行期间仅允许创建一次"); } this.navigationView = navigationView; this.frame = frame; this.navigationView.ItemInvoked += this.OnItemInvoked; this.BackRequestedEventHandler += this.OnBackRequested; TitleBar.AddBackRequestedHandler(window, this.BackRequestedEventHandler); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); var frame = new ThemeAwareFrame { Source = new Uri("MainPage.xaml", UriKind.Relative), }; var window = new Window { Content = frame }; window.SetBinding(TitleBar.IsBackButtonVisibleProperty, new Binding("CanGoBack") { Source = frame }); TitleBar.AddBackRequestedHandler(window, delegate { frame.GoBack(); }); window.Show(); }