コード例 #1
0
        public async Task TransitionForward(DependencyObject previousPage, DependencyObject newPage)
        {
            if (previousPage == null && newPage == null)
            {
                throw new InvalidOperationException();
            }

            if (previousPage == null)
            {
                await ForwardInAnimation.Animate(newPage);
            }
            else if (newPage == null)
            {
                await ForwardOutAnimation.Animate(previousPage);
            }
            else if (this.Mode == PageTransitionMode.Parallel)
            {
                var sb    = new Storyboard();
                var outSb = ForwardOutAnimation.GetAnimation(previousPage);
                var inSb  = ForwardInAnimation.GetAnimation(newPage);
                sb.Children.Add(outSb);
                sb.Children.Add(inSb);
                await sb.BeginAsync();

                sb.Stop();
                sb.Children.Clear();
                //await Task.WhenAll(
                //    ForwardOutAnimation.Animate(previousPage),
                //    ForwardInAnimation.Animate(newPage));
            }
            else
            {
                await ForwardOutAnimation.Animate(previousPage);

                await ForwardInAnimation.Animate(newPage);
            }
        }
コード例 #2
0
        /// <summary>
        /// Runs forward transition.
        /// </summary>
        /// <param name="previousPage">The previous page.</param>
        /// <param name="newPage">The new page.</param>
        /// <returns>The task that completes when the transition is complete.</returns>
        /// <exception cref="System.ArgumentNullException"></exception>
        public async Task TransitionForward(DependencyObject previousPage, DependencyObject newPage)
        {
            if (previousPage == null && newPage == null)
            {
                throw new ArgumentNullException("newPage");
            }

            PrepareForwardAnimations(previousPage, newPage);

            UpdateTimelineAttributes();

            if (previousPage == null)
            {
                if (ForwardInAnimation != null)
                {
                    await ForwardInAnimation.Animate(newPage);
                }
            }
            else if (newPage == null)
            {
                if (ForwardOutAnimation != null)
                {
                    await ForwardOutAnimation.Animate(previousPage);
                }
            }
            else if (this.Mode == PageTransitionMode.Parallel)
            {
                var sb = new Storyboard();

                Storyboard outSb = null;
                Storyboard inSb  = null;

                if (this.ForwardOutAnimation != null)
                {
                    outSb = this.ForwardOutAnimation.GetAnimation(previousPage);
                    sb.Children.Add(outSb);
                }

                if (this.ForwardInAnimation != null)
                {
                    inSb = this.ForwardInAnimation.GetAnimation(newPage);
                    sb.Children.Add(inSb);
                }

                await sb.BeginAsync();

                sb.Stop();
                sb.Children.Clear();

                if (this.ForwardOutAnimation != null)
                {
                    this.ForwardOutAnimation.CleanupAnimation(previousPage, outSb);
                }

                if (this.ForwardInAnimation != null)
                {
                    this.ForwardInAnimation.CleanupAnimation(newPage, inSb);
                }
                //await Task.WhenAll(
                //    ForwardOutAnimation.Animate(previousPage),
                //    ForwardInAnimation.Animate(newPage));
            }
            else
            {
                if (this.ForwardOutAnimation != null)
                {
                    await this.ForwardOutAnimation.Animate(previousPage);
                }

                if (this.ForwardInAnimation != null)
                {
                    await this.ForwardInAnimation.Animate(newPage);
                }
            }

            CleanupForwardAnimations(previousPage, newPage);
        }