/// <summary> /// Handles the application of a new Template. /// </summary> public override void OnApplyTemplate() { base.OnApplyTemplate(); PanningTransform = GetTemplateChild(PanningTransformName) as TranslateTransform; _animator = PanningTransform != null ? new TransformAnimator(PanningTransform) : null; }
public static void EnsureAnimator(FrameworkElement targetElement, ref TransformAnimator animator) { if (animator == null) { TranslateTransform transform = TransformAnimator.GetTranslateTransform(targetElement); if (transform != null) { animator = new TransformAnimator(transform); } } if (animator == null) { throw new InvalidOperationException("The animation system could not be prepared for the target element."); } }