Exemplo n.º 1
0
        /// <summary>
        /// Navigates to the target page type without playing any animations
        /// </summary>
        /// <param name="pageType">The type of the target page</param>
        /// <param name="parameter">The optional parameter</param>
        public bool NavigateWithoutAnimations(Type pageType, [Optional] object parameter)
        {
            bool eventPending = IsEmpty;
            bool result       = base.Navigate(pageType, parameter);

            if (eventPending)
            {
                EmptyContentStateChanged?.Invoke(this, false);
            }
            return(result);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Clears the Frame content and its navigation stack without any animation
 /// </summary>
 public void ResetFrame()
 {
     BackStack.Clear();
     if (Content != null)
     {
         try
         {
             // This call causes the current page to execute the OnNavigatedFrom method
             GetNavigationState();
         }
         catch
         {
             // Doesn't matter
         }
     }
     Content = null;
     EmptyContentStateChanged?.Invoke(this, true);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Navigates to the target page type
        /// </summary>
        /// <param name="pageType">The type of the target page</param>
        /// <param name="parameter">The optional parameter</param>
        public new async Task <bool> Navigate(Type pageType, [Optional] object parameter)
        {
            // Avoid accidental inputs while the Frame is navigating
            IsHitTestVisible = false;

            // Create the TaskCompletionSource to await the end of the async method
            TaskCompletionSource <bool> tcs = new TaskCompletionSource <bool>();

            // Prepare the action that will call the base navigation method and finish the animations
            Action <bool> finishNavigation = async empty =>
            {
                // Set the CustomFrame up before the navigation
                Opacity = 0;
                bool navResult = base.Navigate(pageType, parameter);
                if (empty)
                {
                    BackStack.Clear();
                }
                FrameworkContent.SetVisualOpacity(0);
                Opacity = 1;

                // Setup the right animation
                await GetContentForwardInStoryboard();

                IsHitTestVisible = true;
                tcs.SetResult(navResult);
            };

            // If the current content is not null, animate the fade out for the current page
            if (Content != null)
            {
                await GetContentForwardOutStoryboard();

                finishNavigation(false);
            }
            else
            {
                EmptyContentStateChanged?.Invoke(this, false);
                finishNavigation(true);
            }

            // Wait for all the animations to finish and then return the navigation result
            return(await tcs.Task);
        }