public static void EnsureAnimator(UIElement targetElement, ref OpacityAnimator animator) { if (animator == null) { animator = new OpacityAnimator(targetElement); } if (animator == null) { throw new InvalidOperationException("The animation system could not be prepared for the target element."); } }