tags:

views:

456

answers:

2

In my WPF Application I have a canvas with a Listbox in it. I want to overlay an Listboxitem with another control after it was clicked on the item. But for that I need the position of the Listboxitem in the canvas. I see the problem because the single Item is not child of the canvas. Only the Listbox itself is.

Is there any way I can get the relative position of the ListboxItem in the canvas or maybe the absolute position inside the window?

A: 

This is not a direct answer to your question, but I wonder if the Adorner concept of WPF may give you what you want.

Daniel Pratt
Looks useful. Not what I had in mind but I will have a look.
Holli
+2  A: 

try this code:

Point p = listboxItem.TranslatePoint(new Point(0.0,0.0),Window.GetWindow(listboxItem));

In order to get it relative to the canvas, replace the new Point to the canavas location.

HTH.

Satumba
I found the time to try this. Works like a dream. Thanks.
Holli