title: WPF: Get position of child UIElement within its parent. Ignore RenderTransform if any
body: <p>Lets say I have this XAML code:</p>
  
  <pre><code>&lt;DockPanel Name="pan"&gt;
      &lt;Label Content="AAA" Name="lab1" /&gt;
      &lt;Label Content="BBB" Name="lab2" /&gt;
      &lt;Label Content="CCC" Name="lab3" /&gt;
  &lt;/DockPanel&gt;
  </code></pre>
  
  <p>I my code behind I want to find out what are the coordinates of <code>lab2</code> within <code>pan</code>. <strong>Hovewer</strong> I want to ignore any present RenderTransform of <code>lab2</code>. So the solution must return same coordinates for above code and following:</p>
  
  <pre><code>&lt;DockPanel&gt;
      &lt;Label Content="AAA" /&gt;
      &lt;Label Content="BBB" &gt;
          &lt;Label.RenderTransform&gt;
              &lt;TranslateTransform Y="20"/&gt;
          &lt;/Label.RenderTransform&gt;
      &lt;/Label&gt;
      &lt;Label Content="CCC" /&gt;
  &lt;/DockPanel&gt;
  </code></pre>
  
  <p>In another words I want the position that was set by the <code>ArrangeOverride</code> method of <code>pan</code> when calling <code>Arrange</code> on <code>but2</code>. I would call it 'logical position'. The 'visual position' can be obtained by calling following method:</p>
  
  <pre><code>private Point visualPoss() {
      Point lab2Vis = lab2.PointToScreen(new Point(0, 0));
      Point panVis = pan.PointToScreen(new Point(0, 0));
      return new Point(lab2Vis.X - panVis.X, lab2Vis.Y - panVis.Y);
  } 
  </code></pre>
  
  <p>But this is not a solution of my problem as the return value of this <code>visualPoss()</code> is not equal for both XAML code examples above.</p>
  
  <p>Please leave comment if somehing is unclear.</p>
  
  <p>Thank you</p>