How to change z-order of Wpf AdornerLayer children?
-
15-06-2021 - |
سؤال
I have an image editing application, and I have custom adorners which get added to an AdornerLayer. When the user clicks on an Adorner, I want to bring it to top - meaning if it is dragged over another adorner, I want the first click to be caught by the topmost adorner.
I can't figure out how to change the z-order of the child elements of the AdornerLayer. It doesn't seem to allow me to sort them. Even if I remove and re-add the Adorner, it doesn't get topmost.
المحلول
Please have a look on that,
http://social.msdn.microsoft.com/forums/en-us/wpf/thread/C6780661-EF6D-4141-B4CA-0C7A2461D314
نصائح أخرى
I had a similar problem, but just needed a specific ordering of my adorners. I ended up using reflection to set the orders:
var setZOrderMethodInfo = adornerLayer.GetType().GetMethod("SetAdornerZOrder", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
setZOrderMethodInfo.Invoke(adornerLayer, new object[] { adorner1, 0 });
setZOrderMethodInfo.Invoke(adornerLayer, new object[] { adorner2, 1 });
from http://social.msdn.microsoft.com/Forums/en/wpf/thread/40bff84e-c4b5-4ea0-87ea-43461df9f24b