/// <summary> /// Checks whether given visual is a part of Snoop's visual tree. /// </summary> /// <param name="visual">Visual under question</param> /// <returns><c>true</c> if <paramref name="visual"/> belongs to Snoop's visual tree. <c>false</c> otherwise.</returns> public static bool IsPartOfSnoopVisualTree(this Visual visual) { if (visual == null) { return(false); } if (SnoopAttachedProperties.GetIsSnoopPart(visual)) { return(true); } foreach (var registeredSnoopVisual in registeredSnoopVisualTreeRoots.ToList()) { if (registeredSnoopVisual.IsAlive == false) { registeredSnoopVisualTreeRoots.Remove(registeredSnoopVisual); continue; } var snoopVisual = (Visual)registeredSnoopVisual.Target; if (ReferenceEquals(visual, snoopVisual) || (visual.Dispatcher == snoopVisual.Dispatcher && visual.IsDescendantOf(snoopVisual))) { return(true); } } return(false); }
public AdornerContainer(UIElement adornedElement) : base(adornedElement) { SnoopAttachedProperties.SetIsSnoopPart(this, true); }