private void App_BackRequested(object sender, BackRequestedEventArgs e)
 {
     OnBackRequested?.Invoke(this, e);
     if (!e.Handled)
     {
         if (Frame.CanGoBack)
         {
             Frame.GoBack();
             e.Handled = true;
         }
     }
 }
示例#2
0
        /// <summary>
        /// Virtual method used by the <see cref="GoBackCommand"/> property
        /// to invoke the <see cref="Windows.UI.Xaml.Controls.Frame.GoBack()"/> method.
        /// </summary>
        public virtual void GoBack()
        {
            if (Frame != null && Frame.CanGoBack)
            {
                FrameBackRequestedEventArgs eventArgs = new FrameBackRequestedEventArgs();
                OnBackRequested?.Invoke(this, eventArgs);

                if (eventArgs == null || !eventArgs.IsHandled)
                {
                    Frame.GoBack();
                }
            }
        }
示例#3
0
        private void AppBackRequested(object sender, BackRequestedEventArgs e)
        {
            OnBackRequested?.Invoke(this, e);

            if (!e.Handled)
            {
                // Default is to navigate back within the Frame
                Frame frame = Window.Current.Content as Frame;
                if (frame.CanGoBack)
                {
                    frame.GoBack();
                    // Signal handled so that system doesn't navigate back through app stack
                    e.Handled = true;
                }
            }
        }
示例#4
0
文件: App.xaml.cs 项目: mutzl/YANApp
        private void AppBackRequested(object sender, BackRequestedEventArgs e)
        {
            OnBackRequested?.Invoke(this, e);

            if (!e.Handled)
            {
                // Default is to navigate back within the Frame
                Frame frame = Window.Current.Content as Frame;
                if (frame.CanGoBack)
                {
                    frame.GoBack();
                    // Signal handled so that system doesn't navigate back through app stack
                    e.Handled = true;
                }
            }
        }
示例#5
0
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (Debugger.IsAttached)
            {
                DebugSettings.EnableFrameRateCounter = true;
            }
#endif
            var rootFrame = Window.Current.Content as Frame;

            if (rootFrame == null)
            {
                rootFrame = new Frame();

                rootFrame.NavigationFailed +=
                    (sender, args) => { throw new Exception("Failed to load Page " + args.SourcePageType.FullName); };

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Zustand von zuvor angehaltener Anwendung laden
                }

                Window.Current.Content = rootFrame;

                //Handle the BackRequested Event
                SystemNavigationManager.GetForCurrentView().BackRequested += (sender, eventArgs) =>
                {
                    //If an EventHandler is registered for the OnBackRequested event: call it
                    //Maybe the EventHandler will handled this event
                    OnBackRequested?.Invoke(this, eventArgs);

                    if (!eventArgs.Handled)
                    {
                        var frame = Window.Current.Content as Frame;
                        if (frame != null && frame.CanGoBack)   //If we can go back, go back
                        {
                            eventArgs.Handled = true;
                            frame.GoBack();
                        }
                    }
                };

                //Whenever we navigate to a new page, set the AppViewBackButton to visible if we can go back, to collapsed if we dont
                rootFrame.Navigated += (sender, args) =>
                {
                    SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility
                        = rootFrame.CanGoBack
                            ? AppViewBackButtonVisibility.Visible
                            : AppViewBackButtonVisibility.Collapsed;
                };
            }

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    rootFrame.Navigate(typeof(StartPage), e.Arguments);
                }
                Window.Current.Activate();
            }
        }
示例#6
0
 /// Called when the back button has been tapped
 ///
 public void OnBackTapped()
 {
     OnBackRequested.SafeInvoke();
 }