protected override void OnStartup(StartupEventArgs e) { _rootFrame = new Frame(); _rootFrame.NavigationUIVisibility = NavigationUIVisibility.Hidden; _dependemcyInjection = new DependencyInjection(); DefineConfigurations(); _navigationManager = new NavigationManager(_dependemcyInjection); var window = _dependemcyInjection .DefineDependency <MainWindow>(0, _rootFrame).Resolve <MainWindow>(); window.Top = 50; window.Left = 50; Current.MainWindow = window; NavigationEventHub.Navigated += OnNavigated; NavigationEventHub.Navigating += OnNavigating; NavigationEventHub.NavigationFailed += OnNavigationFailed; if (_rootFrame.Content == null) { var page = _dependemcyInjection.Resolve <SourceUpdatesPage>(); _rootFrame.Navigate(page); NavigationEventHub.OnNavigated(this, new global::WPF.Tools.Navigation.Events.NavigationEventArgs("Updates", new object[] { })); } window.Show(); }
public static bool GoBack() { var navigated = false; if (CanGoBack()) { if (GetRootFrame() is Frame mainFrame) { _nextPageTitle = _pageTitle; _nextPage = _actualPage; _nextExtraContent = _extraContent; _pageTitle = _previousPageTitle; _actualPage = _previousPage; _extraContent = _previousExtraContent; _previousPageTitle = null; _previousPage = null; _previousExtraContent = null; mainFrame.Content = _actualPage; navigated = true; NavigationEventHub.OnNavigated(_previousPage, new NavigationEventArgs(_pageTitle, _nextPage, _actualPage, _extraContent)); } } return(navigated); }
public void Navigate <T>(string pageTitle, object extra) where T : Page { var page = default(T); try { if (GetRootFrame().Content != null && GetRootFrame().Content is Page pg) { _previousPageTitle = pageTitle; _previousPage = pg; _previousExtraContent = _extraContent; } page = _dependencyInjection.Resolve <T>(); NavigationEventHub.OnNavigating(_previousPage, new NavigationEventArgs(pageTitle, page, extra)); _actualPage = page; GetRootFrame().Content = page; _extraContent = extra; _pageTitle = pageTitle; page.Loaded += Page_Loaded; } catch (Exception e) { NavigationEventHub.OnNavigationFailed(page, new NavigationFailedEventArgs(pageTitle, _previousPage, typeof(T), extra, e)); } }
private void Page_Loaded(object sender, RoutedEventArgs e) { NavigationEventHub.OnNavigated(_actualPage, new NavigationEventArgs(_pageTitle, _previousPage, _actualPage, _extraContent)); }