I have a stackpanel that has N-number of children. I want to get the x,y coordinates of the children relative to the parent stackpanel.
The children in the stackpanel are centered horizontally so whenever the stackpanel resizes the children are centered. Here's what I'm doing to get the TopLeft corner of the child item relative to the StackPanel:
Dim parent = VisualTreeHelper.GetParent(childItem)
childItem.TranslatePoint(VisualTreeHelper.GetDescendantBounds(childItem).TopLeft, parent)
Let's say in the initial layout the point it gives me back is (20,0). Now the layout changes and the stackpanel widens, but the children remain centered. I would expect this method now to give me something back like (150, 0) but it's still giving me (20,0). Visually I can see the items are in the center of the StackPanel, but it's still giving me the initial coordinates. What am I doing wrong?