public async Task TransitionBackward(DependencyObject previousPage, DependencyObject newPage) { if (previousPage == null && newPage == null) { throw new InvalidOperationException(); } if (previousPage == null) { await BackwardInAnimation.Animate(newPage); } else if (newPage == null) { await BackwardOutAnimation.Animate(previousPage); } else if (this.Mode == PageTransitionMode.Parallel) { var sb = new Storyboard(); var outSb = BackwardOutAnimation.GetAnimation(previousPage); var inSb = BackwardInAnimation.GetAnimation(newPage); sb.Children.Add(outSb); sb.Children.Add(inSb); await sb.BeginAsync(); sb.Stop(); sb.Children.Clear(); //await Task.WhenAll( // BackwardOutAnimation.Animate(previousPage), // BackwardInAnimation.Animate(newPage)); } else { await BackwardOutAnimation.Animate(previousPage); await BackwardInAnimation.Animate(newPage); } }
/// <summary> /// Runs backward 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 TransitionBackward(DependencyObject previousPage, DependencyObject newPage) { if (previousPage == null && newPage == null) { throw new ArgumentNullException("newPage"); } PrepareBackwardAnimations(previousPage, newPage); UpdateTimelineAttributes(); if (previousPage == null) { await BackwardInAnimation.Animate(newPage); } else if (newPage == null) { await BackwardOutAnimation.Animate(previousPage); } else if (this.Mode == PageTransitionMode.Parallel) { var sb = new Storyboard(); Storyboard outSb = null; Storyboard inSb = null; if (this.BackwardOutAnimation != null) { outSb = this.BackwardOutAnimation.GetAnimation(previousPage); sb.Children.Add(outSb); } if (this.BackwardInAnimation != null) { inSb = this.BackwardInAnimation.GetAnimation(newPage); sb.Children.Add(inSb); } await sb.BeginAsync(); sb.Stop(); sb.Children.Clear(); if (this.BackwardOutAnimation != null) { this.BackwardOutAnimation.CleanupAnimation(previousPage, outSb); } if (this.BackwardInAnimation != null) { this.BackwardInAnimation.CleanupAnimation(newPage, inSb); } //await Task.WhenAll( // BackwardOutAnimation.Animate(previousPage), // BackwardInAnimation.Animate(newPage)); } else { if (this.BackwardOutAnimation != null) { await this.BackwardOutAnimation.Animate(previousPage); } if (this.BackwardInAnimation != null) { await this.BackwardInAnimation.Animate(newPage); } } CleanupBackwardAnimations(previousPage, newPage); }