title: How do I determine the coordinates of an item within a stackpanel?
body: <p>I have a <code>StackPanel</code> that has N-number of children. I want to get the x,y coordinates of the children relative to the parent <code>StackPanel</code>.</p>
  
  <p>The children in the <code>StackPanel</code> are centered horizontally so whenever the <code>StackPanel</code> resizes the children are centered. Here's what I'm doing to get the TopLeft corner of the child item relative to the <code>StackPanel</code>:</p>
  
  <pre><code>Dim parent = VisualTreeHelper.GetParent(childItem)
  childItem.TranslatePoint(VisualTreeHelper.GetDescendantBounds(childItem).TopLeft, parent)
  </code></pre>
  
  <p>Let's say in the initial layout the point it gives me back is (20,0). Now the layout changes and the <code>StackPanel</code> 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 <code>StackPanel</code>, but it's still giving me the initial coordinates. What am I doing wrong?</p>