protected internal override void BeginTransition(TransitionPresenter transitionElement, ContentPresenter oldContent, ContentPresenter newContent) { TranslateTransform tt = new TranslateTransform(StartPoint.X * transitionElement.ActualWidth, StartPoint.Y * transitionElement.ActualHeight); if (IsNewContentTopmost) { newContent.RenderTransform = tt; } else { oldContent.RenderTransform = tt; } DoubleAnimation da = new DoubleAnimation(EndPoint.X * transitionElement.ActualWidth, Duration); da.EasingFunction = new SineEase() { EasingMode = EasingMode.EaseOut }; tt.BeginAnimation(TranslateTransform.XProperty, da); da.To = EndPoint.Y * transitionElement.ActualHeight; da.Completed += delegate { EndTransition(transitionElement, oldContent, newContent); }; tt.BeginAnimation(TranslateTransform.YProperty, da); }
// Don't update content until done transitioning private static object CoerceContent(object element, object value) { TransitionPresenter te = (TransitionPresenter)element; if (te.IsTransitioning) { return(te.CurrentContentPresenter.Content); } return(value); }
private static object CoerceTransition(object element, object value) { TransitionPresenter te = (TransitionPresenter)element; if (te.IsTransitioning) { return(te._activeTransition); } return(value); }
// Force clip to be true if the active Transition requires it private static object CoerceClipToBounds(object element, object value) { TransitionPresenter transitionElement = (TransitionPresenter)element; bool clip = (bool)value; if (!clip && transitionElement.IsTransitioning) { Transition transition = transitionElement.Transition; if (transition.ClipToBounds) { return(true); } } return(value); }
private static void OnContentTemplateSelectorChanged(object element, DependencyPropertyChangedEventArgs e) { TransitionPresenter te = (TransitionPresenter)element; te.CurrentContentPresenter.ContentTemplateSelector = (DataTemplateSelector)e.NewValue; }
private static void OnContentChanged(object element, DependencyPropertyChangedEventArgs e) { TransitionPresenter te = (TransitionPresenter)element; te.BeginTransition(); }
//Transitions can override this to perform cleanup at the end of the transition protected virtual void OnTransitionEnded(TransitionPresenter transitionElement, ContentPresenter oldContent, ContentPresenter newContent) { }
//Transitions should call this method when they are done protected void EndTransition(TransitionPresenter transitionElement, ContentPresenter oldContent, ContentPresenter newContent) { OnTransitionEnded(transitionElement, oldContent, newContent); transitionElement.OnTransitionCompleted(); }
// Called when an element is Removed from the TransitionPresenter's visual tree protected internal virtual void BeginTransition(TransitionPresenter transitionElement, ContentPresenter oldContent, ContentPresenter newContent) { EndTransition(transitionElement, oldContent, newContent); }
protected override void OnTransitionEnded(TransitionPresenter transitionElement, ContentPresenter oldContent, ContentPresenter newContent) { newContent.ClearValue(ContentPresenter.RenderTransformProperty); oldContent.ClearValue(ContentPresenter.RenderTransformProperty); }