/// <summary> /// Calls the <see cref="OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs)"/> method /// for this control and all of its visual descendents. /// </summary> /// <param name="e">The event args.</param> private void NotifyDetachedFromVisualTree(VisualTreeAttachmentEventArgs e) { _visualLogger.Verbose("Detached from visual tree"); VisualRoot = null; OnDetachedFromVisualTree(e); if (VisualChildren != null) { foreach (Visual child in VisualChildren.OfType <Visual>()) { child.NotifyDetachedFromVisualTree(e); } } }
/// <summary> /// Calls the <see cref="OnAttachedToVisualTree(VisualTreeAttachmentEventArgs)"/> method /// for this control and all of its visual descendents. /// </summary> /// <param name="e">The event args.</param> private void NotifyAttachedToVisualTree(VisualTreeAttachmentEventArgs e) { _visualLogger.Verbose("Attached to visual tree"); VisualRoot = e.Root; OnAttachedToVisualTree(e); if (VisualChildren != null) { foreach (Visual child in VisualChildren.OfType <Visual>()) { child.NotifyAttachedToVisualTree(e); } } }
/// <summary> /// Calls the <see cref="OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs)"/> method /// for this control and all of its visual descendents. /// </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); if (VisualChildren != null) { foreach (Visual child in VisualChildren.OfType <Visual>()) { child.OnDetachedFromVisualTreeCore(e); } } }
/// <summary> /// Calls the <see cref="OnAttachedToVisualTree(VisualTreeAttachmentEventArgs)"/> method /// for this control and all of its visual descendants. /// </summary> /// <param name="e">The event args.</param> protected virtual void OnAttachedToVisualTreeCore(VisualTreeAttachmentEventArgs e) { Logger.Verbose(LogArea.Visual, this, "Attached to visual tree"); _visualRoot = e.Root; if (RenderTransform != null) { RenderTransform.Changed += RenderTransformChanged; } OnAttachedToVisualTree(e); AttachedToVisualTree?.Invoke(this, e); InvalidateVisual(); if (VisualChildren != null) { foreach (Visual child in VisualChildren.OfType <Visual>()) { child.OnAttachedToVisualTreeCore(e); } } }
/// <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); if (VisualChildren != null) { foreach (Visual child in VisualChildren.OfType <Visual>()) { child.OnDetachedFromVisualTreeCore(e); } } }