2

I am new to WPF and I have been searching for the solution on this for a while now. My goal is listen to the UIElement's adorner resize event, that's why I need to get the element's adorner. I have searched for similar problem but I only found the ones that created or have direct access to the adorner class. In my case however, the adorner was created when the UIElement was added to the Scrollviewer. In case you want to know I am working on a thermal label editor.

I am currently able to get the UIElement, scrollviewer, and the scrollcontent presenter which has the AdornerLayer where the adorners are rendered as I have read on a post. But I still couldn't see the adorners on the AdornerLayer object, as I have tried from this post: Copy UI element with adorner

Here is a screenshot of the WPF Visualizer. http://codetampus.com/wpfvisualizer.png

I hope someone could help and enlighten me with this, maybe I have just missed something.

Community
  • 1
  • 1
johnsabre
  • 355
  • 2
  • 7
  • could you post xaml for the same and also mark the target element. I may try to find a way to attach the resize event to the adorner layer – pushpraj Jun 28 '14 at 09:13
  • I believe I can't provide the xaml code for this since the uielements are created only when running the app and creating a new item through the themal label API, which is in C# side. So to get the uielement I have to do it after the adding of the item is done: private UIElementCollection GetThermalObjects() { var obj = ((Grid)((Grid)((ScrollViewer)thermalLabelEditor1.Children[0]).Content).Children[0]).Children[0]; var itemscollection = ((Canvas)VisualTreeHelper.GetChild(obj, 1)).Children; return itemscollection; }>' – johnsabre Jun 28 '14 at 09:23
  • you are looking for adorner layer shown in the picture or the adorner layer of the elements within the grid just above the adorner layer? seems like the code you've posted is returning the elements in the grid. Also could you share what you are trying to achieve, might there be a way to achieve the same using other simple methods. – pushpraj Jun 28 '14 at 11:00
  • I was looking for the adorner layer of the elements within the grid above of the selected adorner layer on the picture. But this was the part where I was confused, since I can't see an adorner layer within the grid only the adorner layer below the grid. I just came across an interesting tool for which I think works like chrome developer tool: [WPF Inspector](http://wpfinspector.codeplex.com/) which showed that the unnamed object within the grid to have the adorner rectangles. I will edit my post for the screenshot. – johnsabre Jun 28 '14 at 12:10
  • here is the screenshot of the tool: [WPFInspector](http://codetampus.com/wpfinspector.png) – johnsabre Jun 28 '14 at 12:17
  • those objects are not unnamed but those are obfuscated so we cant see the type or implementation within. secondly there is no adorner layer attached to those elements. So it is difficult to get those objects and adorner layer is no way. But I am still looking for what you are trying to achieve. May I help you achieve the same. – pushpraj Jun 28 '14 at 12:43
  • Thanks so much for your help @pushpraj, I am actually trying to update the location (x and y points) of all the thermal label objects which are UIElements right after the user lets go of the adorner handle which is after any element has been resized. I also have to achieve other things on the elements. Thanks for the info on obfuscation. Now I understand why there are weird characters of the object type when I try to expand classes. – johnsabre Jun 28 '14 at 13:13
  • I am not familiar with thermal label editor. So if you could send me a small sample of your app. I may try to see what we can do. – pushpraj Jun 28 '14 at 13:36
  • @pushpraj, I could send you a sample of my app. How will I send it to you? – johnsabre Jun 29 '14 at 10:34
  • You may upload to any file sharing service of your choice. google drive is one of them and share the link here. – pushpraj Jun 29 '14 at 12:28

0 Answers0