Exemple #1
0
        protected override void OnPause()
        {
            base.OnPause();

            VisualTreeHelper.CloseAllPopups();

            DismissKeyboard();
        }
Exemple #2
0
        private void Initialize()
        {
            // Dismiss on device rotation: this reproduces the windows behavior
            UIApplication.Notifications
            .ObserveDidChangeStatusBarOrientation((sender, args) => VisualTreeHelper.CloseAllPopups());

            // Dismiss when the app is entering background
            UIApplication.Notifications
            .ObserveWillResignActive((sender, args) => VisualTreeHelper.CloseAllPopups());
        }
Exemple #3
0
        private bool InnerNavigate(PageStackEntry entry, NavigationMode mode)
        {
            try
            {
                // Navigating
                var navigatingFromArgs = new NavigatingCancelEventArgs(
                    mode,
                    entry.NavigationTransitionInfo,
                    entry.Parameter,
                    entry.SourcePageType
                    );

                Navigating?.Invoke(this, navigatingFromArgs);

                CurrentEntry?.Instance.OnNavigatingFrom(navigatingFromArgs);

                if (navigatingFromArgs.Cancel)
                {
                    NavigationStopped?.Invoke(this, new NavigationEventArgs(
                                                  entry.Instance,
                                                  mode,
                                                  entry.NavigationTransitionInfo,
                                                  entry.Parameter,
                                                  entry.SourcePageType,
                                                  null
                                                  ));
                    return(false);
                }

                // Navigate
                var previousEntry = CurrentEntry;
                CurrentEntry = entry;

                if (mode == NavigationMode.New)
                {
                    // Doing this first allows CurrentEntry to reuse existing page if pooling is enabled
                    ReleasePages(ForwardStack);
                }

                if (CurrentEntry.Instance == null)
                {
                    var page = CreatePageInstanceCached(entry.SourcePageType);
                    if (page == null)
                    {
                        return(false);
                    }

                    page.Frame            = this;
                    CurrentEntry.Instance = page;
                }

                Content = CurrentEntry.Instance;

                switch (mode)
                {
                case NavigationMode.New:
                    ForwardStack.Clear();
                    if (previousEntry != null)
                    {
                        BackStack.Add(previousEntry);
                    }
                    break;

                case NavigationMode.Back:
                    ForwardStack.Add(previousEntry);
                    BackStack.Remove(CurrentEntry);
                    break;

                case NavigationMode.Forward:
                    BackStack.Add(previousEntry);
                    ForwardStack.Remove(CurrentEntry);
                    break;

                case NavigationMode.Refresh:
                    break;
                }

                // Navigated
                var navigationEvent = new NavigationEventArgs(
                    CurrentEntry.Instance,
                    mode,
                    entry.NavigationTransitionInfo,
                    entry.Parameter,
                    entry.SourcePageType,
                    null
                    );

                previousEntry?.Instance.OnNavigatedFrom(navigationEvent);
                CurrentEntry.Instance.OnNavigatedTo(navigationEvent);
                Navigated?.Invoke(this, navigationEvent);

                VisualTreeHelper.CloseAllPopups();

                return(true);
            }
            catch (Exception exception)
            {
                NavigationFailed?.Invoke(this, new NavigationFailedEventArgs(entry.SourcePageType, exception));
                return(false);
            }
        }