- Why is that the adorner layer is always rendered as the top most layer in an application (under AdornerDecorator - refer screenshot)?
- Is there a way to change the layer/level on to which the adorners can be drawn?
In the following screenshot, AdornerLayer is added to AdornerDecorator and the Adorners (MyAdorners) are added to this AdornerLayer. But the AdornerLayer is retrieved like this,
AdornerLayer layer1 = AdornerLayer.GetAdornerLayer(button1);
layer1.Add(new MyAdorner(button1));
To answer my second question,
I guess I have found a solution. Just place an AdornerDecorator element around the level on to which the adorners needs to be rendered. Any control requiring an adorner layer would use this AdornerDecorator element to place its decorators.
Here I have moved the adorners to a different level using the following code snippet.
While the AdornerLayer is still queried in the same way,
Kindly correct me if I am wrong.
Adorner layer is provided by AdornerDecorator. When you ask for the layer for the given control wpf looks for the AdornerDecorator upper visual tree. Why do you need to change this logic? Adorners system made intentionally this way for decorations to appear above the decorated element.
You can search for AdornerDecorator yourself with VisualTreeHelper