/// <summary> /// Connects a <see cref="FrameworkElement"/> to its parent <see cref="AttachedShadowBase"/> definition. /// </summary> /// <param name="parent">The <see cref="AttachedShadowBase"/> that is using this context.</param> /// <param name="element">The <see cref="FrameworkElement"/> that a shadow is being attached to.</param> internal void ConnectToElement(AttachedShadowBase parent, FrameworkElement element) { if (_isConnected) { throw new InvalidOperationException("This AttachedShadowElementContext has already been connected to an element"); } _isConnected = true; Parent = parent ?? throw new ArgumentNullException(nameof(parent)); Element = element ?? throw new ArgumentNullException(nameof(element)); Element.Loaded += OnElementLoaded; Element.Unloaded += OnElementUnloaded; Initialize(); }
/// <summary> /// Attaches a shadow to an element by setting the <see cref="ShadowProperty"/> property. /// </summary> /// <param name="obj">The <see cref="FrameworkElement"/> to attach the shadow to.</param> /// <param name="value">The <see cref="AttachedShadowBase"/> that will be attached to the element</param> public static void SetShadow(FrameworkElement obj, AttachedShadowBase value) { obj.SetValue(ShadowProperty, value); }