protected override async void OnContentChanged(object oldContent, object newContent) { if (NavigationAnimation == null) { NavigationAnimation = new JumpLeftNavigationAnimation(); } base.OnContentChanged(oldContent, newContent); var oldElement = oldContent as UIElement; var newElement = newContent as UIElement; // Check if the template has been applied correctly if (_firstContentPresenter == null || _secondContentPresenter == null || newElement == null) { return; } _animating = true; try { AnimationDefinition closeAnimation; AnimationDefinition openAnimation; bool sequential; if (_oneOff) { _oneOff = false; closeAnimation = OneOffAnimation_Close; openAnimation = OneOffkAnimation_Open; sequential = OneOffAnimation_Sequential; } else if (_isForwardNavigation) { closeAnimation = NavigationAnimation.ForwardAnimationCloseOld; openAnimation = NavigationAnimation.ForwardAnimationOpenNew; sequential = NavigationAnimation.ForwardAnimationSequential; } else { closeAnimation = NavigationAnimation.BackAnimationCloseTop; openAnimation = NavigationAnimation.BackAnimationReOpenBottom; sequential = NavigationAnimation.BackAnimationSequential; } AnimationManager.ClearAnimationProperties(_oldContentPresenter); _oldContentPresenter.Opacity = 1; _oldContentPresenter.CacheMode = BitmapCacheMode; _oldContentPresenter.Visibility = Visibility.Visible; _oldContentPresenter.Content = oldElement; _oldContentPresenter.IsHitTestVisible = false; AnimationManager.ClearAnimationProperties(_newContentPresenter); _newContentPresenter.Opacity = 0; _newContentPresenter.CacheMode = BitmapCacheMode; _newContentPresenter.Visibility = Visibility.Visible; _newContentPresenter.Content = newElement; _newContentPresenter.IsHitTestVisible = false; if (openAnimation == null) { _newContentPresenter.Opacity = 1; } if ((_isForwardNavigation && !NavigationAnimation.ForwardAnimationReveal) || (!_isForwardNavigation && NavigationAnimation.BackAnimationReveal)) { Canvas.SetZIndex(_newContentPresenter, 1); Canvas.SetZIndex(_oldContentPresenter, 0); } else { Canvas.SetZIndex(_newContentPresenter, 0); Canvas.SetZIndex(_oldContentPresenter, 1); } if (sequential) { if (closeAnimation != null) { await _oldContentPresenter.AnimateAsync(closeAnimation); } if (openAnimation != null) { await _newContentPresenter.AnimateAsync(openAnimation); } } else { var list = new List <Task <FrameworkElement> >(); if (closeAnimation != null) { list.Add(_oldContentPresenter.AnimateAsync(closeAnimation)); } if (openAnimation != null) { list.Add(_newContentPresenter.AnimateAsync(openAnimation)); } await Task.WhenAll(list); } } finally { _oldContentPresenter.Visibility = Visibility.Collapsed; _oldContentPresenter.Content = null; _newContentPresenter.CacheMode = null; _newContentPresenter.Opacity = 1; _newContentPresenter.IsHitTestVisible = true; _animating = false; } }