Here’s the background for my question:
- I would like to know if a particular
System.Windows.Documents.AdornerLayeris empty or not. - “OK, I’ll make the check
myAdornerLayer.VisualChildrenCount > 0.” - “Oh well, the property
AdornerLayer.VisualChildrenCountis protected.” (It overridesSystem.Windows.FrameworkElement.VisualChildrenCountwhich is also protected.) - “Hm… That won’t stop me. I’ll just access
myAdornerLayer.VisualChildrenCountvia reflection.” - “On the other hand, maybe doing this will have some sort of bad side effect. Maybe
VisualChildrenCounthas been protected for a reason. I’ll ask Stack Overflow”.
If using reflection is a bad idea, do you have a suggestion for another way of finding out if an AdornerLayer is empty or not?
There is
Visual Tree Helperclass, that was made for this purpose..http://bing.com/search?q=visualTreeHelper