Exemplo n.º 1
0
        private void RaiseForwardRequested()
        {
            DebugWrite();

            var args = new HandledRoutedEventArgs();

            ForwardRequested?.Invoke(null, args);
            if (args.Handled)
            {
                return;
            }
            foreach (var frame in WindowContext.GetForCurrentView().NavigationServices.Select(x => x.FrameFacade))
            {
                frame.RaiseForwardRequested(args);
                if (args.Handled)
                {
                    return;
                }
            }

            NavigationService?.GoForward();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Default Hardware/Shell Back handler overrides standard Back behavior
        /// that navigates to previous app in the app stack to instead cause a backward page navigation.
        /// Views or Viewodels can override this behavior by handling the BackRequested
        /// event and setting the Handled property of the BackRequestedEventArgs to true.
        /// </summary>
        private void RaiseBackRequested(Windows.System.VirtualKey key, ref bool handled)
        {
            DebugWrite();

            var args = new HandledRoutedEventArgs();

            BackRequested?.Invoke(null, args);
            if (handled = args.Handled)
            {
                return;
            }

            var popups = VisualTreeHelper.GetOpenPopups(Window.Current);

            foreach (var popup in popups)
            {
                if (popup.Child is INavigablePage page)
                {
                    if (key == Windows.System.VirtualKey.Escape)
                    {
                        if (popup.Child is INavigatingPage navigating)
                        {
                            navigating.OnBackRequesting(args);
                        }

                        args.Handled = true;
                    }
                    else
                    {
                        page.OnBackRequested(args);
                    }

                    if (handled = args.Handled)
                    {
                        return;
                    }
                }
                else if (popup.Child is ContentDialog dialog)
                {
                    dialog.Hide();
                    return;
                }
                else if (key == Windows.System.VirtualKey.Escape)
                {
                    handled = args.Handled = true;
                    return;
                }
            }

            foreach (var frame in WindowContext.GetForCurrentView().NavigationServices.Select(x => x.FrameFacade).Reverse())
            {
                frame.RaiseBackRequested(args);

                if (handled = args.Handled)
                {
                    return;
                }
            }

            if (NavigationService?.CanGoBack ?? false)
            {
                NavigationService?.GoBack();
            }
        }