I'm currently working on a slightly more complicated adorner. This one is going to be transformed in only one dimension when the user zooms. Unfortunately, this wreaks havoc for the nice 1px hairline border around it (I want it to remain a nice hairline border - even in the dimension of transformation).
Here's my diagnosis of the problem:
Say I apply a scale transform to the adorned UIElement. WPF then calls the following
- Adorned UIElement's ArrangeCore()
- Adorner's MeasureOverride()
- Adorner's ArrangeOverride()
- Adorner's OnRender()
- Adorner's GetDesiredTransform(...)
The last two seems thorougly backwards to me. If I'm reading this right, it means that, when I override GetDesiredTransform it's just too little to late. Yes, I can indeed scale/translate/skew my adorner, but here's the issue: what if I want to do as described above, namely scale in just one dimension and keep a 1px hairline border on the adorner? Well I can't, can I?
If I'm going to use adorners at all, it seems to me that I have to split them up into separate adorners - the ones that are going to scale and the ones that are not. Seems like a lot of work. Am I missing something in terms of the order of calls here? I guess I could trigger OnRender all the way down the visual tree to the leaves but that seems like massive overkill.
You can keep the border separated from the content of the adorner.
Have the content transform, without involving the border.
Can you post how your adorner Template looks like?