示例#1
0
		public override bool OnOptionsItemSelected(IMenuItem item)
		{
			if (item.ItemId == global::Android.Resource.Id.Home)
				BackPressed?.Invoke(this, EventArgs.Empty);

			return base.OnOptionsItemSelected(item);
		}
示例#2
0
        private void OnBackRequested(object sender, BackRequestedEventArgs e)
        {
            Frame frame             = Window.Current.Content as Frame;
            BackPressEventArgs args = new BackPressEventArgs(frame?.CanGoBack, BackPressAction.GoBack);

            BackPressed?.Invoke(this, args);

            switch (args.Action)
            {
            case BackPressAction.Handled:
                e.Handled = true;
                break;

            case BackPressAction.Unhandled:
                e.Handled = false;
                break;

            case BackPressAction.GoBack:
                if (frame?.CanGoBack == true)
                {
                    e.Handled = true;
                    frame.GoBack();
                }
                break;
            }
        }
 public override bool OnOptionsItemSelected(IMenuItem item)
 {
     if (item.ItemId == 16908332)  // Android.Resource.Id.BackButton - which is internal
     {
         BackPressed?.Invoke(this, EventArgs.Empty);
     }
     return(base.OnOptionsItemSelected(item));
 }
        private void _navigationManager_BackRequested(object sender, global::Windows.UI.Core.BackRequestedEventArgs e)
        {
            var cancelEventArgs = new CancelEventArgs();

            BackPressed?.Invoke(sender, cancelEventArgs);
            if (cancelEventArgs.Cancel)
            {
                e.Handled = true;
            }
        }
示例#5
0
        public override void OnBackPressed()
        {
            CancelEventArgs args = new CancelEventArgs();

            BackPressed?.Invoke(this, args);

            if (!args.Cancel)
            {
                base.OnBackPressed();
            }
        }
示例#6
0
        /// <summary>
        /// Handles the back button press and navigates through the history of the root frame.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">Details about the back button press.</param>
        void App_BackRequested(object sender, Windows.UI.Core.BackRequestedEventArgs e)
        {
            if (!(Window.Current.Content is Frame frame))
            {
                return;
            }

            BackPressed?.Invoke(sender, e);

            if (frame.CanGoBack && !e.Handled)
            {
                frame.GoBack();
                e.Handled = true;
            }
        }
 // To support using the Fragment Backstack with back press
 // Override OnBackPress and have it call this utility method
 public void OnBackPressWithFragmentManagement()
 {
     BackPressed?.Invoke(this, EventArgs.Empty);
     if (SupportFragmentManager.BackStackEntryCount > 1)
     {
         // get the fragment to be popped
         SupportFragmentManager.PopBackStackImmediate();
         var entry = SupportFragmentManager.GetBackStackEntryAt(SupportFragmentManager.BackStackEntryCount - 1);
         var frag  = SupportFragmentManager.FindFragmentByTag(entry.Name);
         FragmentPoppedOnBack?.Invoke(null, frag);
     }
     else
     {
         if (SupportFragmentManager.BackStackEntryCount == 1)
         {
             SupportFragmentManager.PopBackStackImmediate();
         }
         base.OnBackPressed();
     }
 }
        private async void NativeAppWindow_BackPressed(object sender, System.ComponentModel.CancelEventArgs e)
        {
            BackPressed?.Invoke(this, e);

            if (e.Cancel)
            {
                return;
            }

            var currentContent = ViewModel?.GetFinalContent();

            if (currentContent != null)
            {
                // We assume going back succeeded
                bool wentBack = true;

                var task = ViewModel.HandleUserInteractionAsync("GoBack", delegate
                {
                    // Sometimes this might happen asynchronously if there was another pending UI action,
                    // but in those cases we would want to cancel the back press anyways. And for the case
                    // of exiting the app, as long as no other pending UI action was occurring, this would
                    // happen synchronously, and return false, and not cancel the back press
                    wentBack = currentContent.GoBack();
                });

                e.Cancel = wentBack;

                try
                {
                    await task;
                }
                catch (Exception ex)
                {
                    ExceptionHelper.ReportHandledException(ex);
                }
            }
        }
示例#9
0
 private void OnBackPressed()
 {
     BackPressed?.Invoke();
 }
 public void BackButtonPressed()
 {
     BackPressed?.Invoke();
 }
示例#11
0
 public override void OnBackPressed()
 {
     BackPressed?.Invoke(this, EventArgs.Empty);
     base.OnBackPressed();
 }
 private void backButton_Click(object sender, EventArgs e)
 {
     BackPressed.Invoke(this, e);
 }
示例#13
0
 private void RaiseBackPressed()
 {
     BackPressed?.Invoke(this, new EventArgs());
 }
 private void Activity_BackPressed(object sender, System.ComponentModel.CancelEventArgs e)
 {
     BackPressed?.Invoke(this, e);
 }
示例#15
0
        public ScoreScreen()
        {
            BuildUI();

            Back.Click += (sender, e) => BackPressed?.Invoke(sender, e);
        }
示例#16
0
 private void Back_Click(object sender, EventArgs e)
 => BackPressed?.Invoke(this, null);