示例#1
0
        /// <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);
            }
        }
示例#2
0
 /// <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);
 }