Just trying to clarify an observation. (I can't seem to find a straight answer from Google). I am doing some image editing using adorners. My images are both in an ItemsControl and as children of an InkCanvas.
When using GetAdornerLayer() for an element within the ItemsControl, I automatically obtain an Adorner Layer over the element within the ItemsTemplate. But if I go further up the visual tree with VisualTreeHelper, I find another AdornerLayer above all the items of the ItemsControl. (The ItemsControl is itself a child of a Grid). On the other hand, when accessing the AdornerLayer for a child of the InkCanvas, I get an adorner layer that lies between the InkCanvas itself and its children.
Hence, in both cases, it seems apparent that WPF is always placing an adornerlayer between a contentcontrol and its children.
Is this indeed the case?
TIA.
It depends on how the
ControlTemplatesof the controls are defined. TheAdornerLayer.GetAdornerLayermethod traverses up the visual tree starting at the specifiedVisualand returns the adorner layer of the firstAdornerDecoratororScrollContentPresenterelement it finds.So WPF doesn't automatically "always placing an adornerlayer between a contentcontrol and its children". It is rather the control author that provides the adorner layer by adding an AdornerDecorator to the visual tree.
If you for example look at the default
ControlTemplatefor theWindow, you will see that it indeed includes an<AdornerDecorator>element.