/// <summary> /// Called when the control is removed from a logical tree. /// </summary> /// <param name="e">The event args.</param> /// <remarks> /// It is vital that if you override this method you call the base implementation; /// failing to do so will cause numerous features to not work as expected. /// </remarks> protected virtual void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) { if (Name != null) { _nameScope?.Unregister(Name); } _isAttachedToLogicalTree = false; _styleDetach.OnNext(Unit.Default); this.TemplatedParent = null; DetachedFromLogicalTree?.Invoke(this, e); foreach (var child in LogicalChildren.OfType <Control>()) { child.OnDetachedFromLogicalTree(e); } }
/// <summary> /// Called when the control is removed from a rooted logical tree. /// </summary> /// <param name="e">The event args.</param> protected virtual void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) { DetachedFromLogicalTree?.Invoke(this, e); }