Exemple #1
0
        /// <summary>
        /// Calls the <see cref="OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs)"/> method
        /// for this control and all of its visual descendants.
        /// </summary>
        /// <param name="e">The event args.</param>
        protected virtual void OnDetachedFromVisualTreeCore(VisualTreeAttachmentEventArgs e)
        {
            Logger.TryGet(LogEventLevel.Verbose)?.Log(LogArea.Visual, this, "Detached from visual tree");

            _visualRoot = null;

            if (RenderTransform != null)
            {
                RenderTransform.Changed -= RenderTransformChanged;
            }

            OnDetachedFromVisualTree(e);
            DetachedFromVisualTree?.Invoke(this, e);
            e.Root?.Renderer?.AddDirty(this);

            var visualChildren = VisualChildren;

            if (visualChildren != null)
            {
                var visualChildrenCount = visualChildren.Count;

                for (var i = 0; i < visualChildrenCount; i++)
                {
                    if (visualChildren[i] is Visual child)
                    {
                        child.OnDetachedFromVisualTreeCore(e);
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Called when the control is removed from a visual 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 OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
        {
            if (RenderTransform != null)
            {
                RenderTransform.Changed -= RenderTransformChanged;
            }

            DetachedFromVisualTree?.Invoke(this, e);
        }
Exemple #3
0
        /// <summary>
        /// Calls the <see cref="OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs)"/> method
        /// for this control and all of its visual descendants.
        /// </summary>
        /// <param name="e">The event args.</param>
        protected virtual void OnDetachedFromVisualTreeCore(VisualTreeAttachmentEventArgs e)
        {
            Logger.Verbose(LogArea.Visual, this, "Detached from visual tree");

            _visualRoot = null;

            if (RenderTransform != null)
            {
                RenderTransform.Changed -= RenderTransformChanged;
            }

            OnDetachedFromVisualTree(e);
            DetachedFromVisualTree?.Invoke(this, e);
            e.Root?.Renderer?.AddDirty(this);

            if (VisualChildren != null)
            {
                foreach (Visual child in VisualChildren.OfType <Visual>())
                {
                    child.OnDetachedFromVisualTreeCore(e);
                }
            }
        }
Exemple #4
0
 /// <summary>
 /// Called when the control is removed from a visual tree.
 /// </summary>
 /// <param name="e">The event args.</param>
 protected virtual void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
 {
     DetachedFromVisualTree?.Invoke(this, e);
 }