title: Can't get the absolute position of TextBlock in Windows 8 XAML with c++/CLI
body: <p>Iam trying to get the absolute position of a textblock but instead I just get the relative position to the element before.</p>
  
  <p>Here is my XAML code:</p>
  
  <pre><code>&lt;Grid Style="{StaticResource LayoutRootStyle}" x:Name="grid_wrapper"&gt;
  
      &lt;Grid.Background&gt;
        &lt;ImageBrush ImageSource="Assets/background_menu.png" /&gt;
      &lt;/Grid.Background&gt;
  
      &lt;Grid x:Name="grid_main"&gt;
        &lt;Grid.ColumnDefinitions&gt;
          &lt;ColumnDefinition Width="430" /&gt;
          &lt;ColumnDefinition Width="*" /&gt;
      &lt;/Grid.ColumnDefinitions&gt;
  
      &lt;Grid Grid.Column="0" x:Name="Sidebar"&gt;
        &lt;Grid.Background&gt;
          &lt;SolidColorBrush Color="#000000" Opacity="0.5" /&gt;
        &lt;/Grid.Background&gt;
  
        &lt;Grid.RowDefinitions&gt;
          &lt;RowDefinition Height="100" /&gt;
          &lt;RowDefinition Height="*" /&gt;
        &lt;/Grid.RowDefinitions&gt;
  
        &lt;Grid Grid.Row="0" x:Name="grid_mainCaption"&gt;
          &lt;Grid.ColumnDefinitions&gt;
              &lt;ColumnDefinition Width="Auto"/&gt;
              &lt;ColumnDefinition Width="*"/&gt;
          &lt;/Grid.ColumnDefinitions&gt;
  
          &lt;Button Grid.Row="0" Style="{StaticResource BackButtonStyleMain}" TabIndex="2" Margin="40,50,0,0" VerticalAlignment="Center" x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}"/&gt;
          &lt;TextBlock x:Uid="Statistics" Margin="120,0,0,0" Text="Statistics" VerticalAlignment="Bottom" FontSize="33" Foreground="Gold" FontFamily="Assets/sui generis rg.ttf#Sui Generis"/&gt;
  
        &lt;/Grid&gt;
        &lt;Grid x:Name="grid_captions" Grid.Row="1" Grid.Column="0" Margin="120,0,0,0"&gt;
          &lt;Grid.RowDefinitions&gt;
            &lt;RowDefinition Height="auto" /&gt;
            &lt;RowDefinition Height="auto" /&gt;
            &lt;RowDefinition Height="auto" /&gt;
            &lt;RowDefinition Height="auto" /&gt;
            &lt;RowDefinition Height="auto" /&gt;
            &lt;RowDefinition Height="auto" /&gt;
            &lt;RowDefinition Height="auto" /&gt;
            &lt;RowDefinition Height="auto" /&gt;
            &lt;RowDefinition Height="auto" /&gt;
            &lt;RowDefinition Height="auto" /&gt;
            &lt;RowDefinition Height="auto" /&gt;
            &lt;RowDefinition Height="auto" /&gt;
            &lt;RowDefinition Height="auto" /&gt;
            &lt;RowDefinition Height="auto" /&gt;
            &lt;RowDefinition Height="auto" /&gt;
            &lt;RowDefinition Height="auto" /&gt;
            &lt;RowDefinition Height="auto" /&gt;
            &lt;RowDefinition Height="auto" /&gt;
            &lt;RowDefinition Height="auto" /&gt; &lt;!-- Spielstand zurücksetzen --&gt;
          &lt;/Grid.RowDefinitions&gt;
          &lt;TextBlock Text="Spielstatistik" Grid.Row="0" FontSize="22" Foreground="Gold" FontFamily="Assets/sui generis rg.ttf#Sui Generis" Margin="0,70,0,70"/&gt;
          &lt;TextBlock Text="Insgesamte Spielzeit" Grid.Row="1" FontSize="16" FontFamily="Assets/sui generis rg.ttf#Sui Generis"/&gt;
          &lt;TextBlock Text="Dauer des letzten Spiels" Grid.Row="2" FontSize="16" FontFamily="Assets/sui generis rg.ttf#Sui Generis" Margin="0,20,0,0"/&gt;
          &lt;TextBlock Text="Dauer des längsten Spiels" Grid.Row="3" FontSize="16" FontFamily="Assets/sui generis rg.ttf#Sui Generis" Margin="0,20,0,0"/&gt;
          &lt;TextBlock Text="Dauer des kürzesten Spiels" Grid.Row="4" FontSize="16" FontFamily="Assets/sui generis rg.ttf#Sui Generis" Margin="0,20,0,0"/&gt;
          &lt;TextBlock Text="Anzahl der gewonnenen Spiele" Grid.Row="5" FontSize="16" FontFamily="Assets/sui generis rg.ttf#Sui Generis" Margin="0,20,0,0"/&gt;
          &lt;TextBlock Text="Anzahl der gewonnenen Turniere" Grid.Row="6" FontSize="16" FontFamily="Assets/sui generis rg.ttf#Sui Generis" Margin="0,20,0,0"/&gt;
          &lt;TextBlock Text="Anzahl der verlorenen Spiele" Grid.Row="7" FontSize="16" FontFamily="Assets/sui generis rg.ttf#Sui Generis" Margin="0,20,0,0"/&gt;
  
          &lt;!-- I want to have the Y-Position of this element --&gt;
          &lt;TextBlock x:Name="Spielstatistik" Text="Anzahl der verlorenen Turniere" Grid.Row="8" FontSize="16" FontFamily="Assets/sui generis rg.ttf#Sui Generis" Margin="0,20,0,0"/&gt; 
  
          &lt;TextBlock Text="Würfelstatistik" Grid.Row="9" FontSize="22" Foreground="Gold" FontFamily="Assets/sui generis rg.ttf#Sui Generis" Margin="0,70,0,70"/&gt;
          &lt;TextBlock Text="Anzahl der Würfe" Grid.Row="10" FontSize="16" FontFamily="Assets/sui generis rg.ttf#Sui Generis" Margin="0,20,0,0"/&gt;
          &lt;TextBlock Text="Anzahl der Pip" Grid.Row="11" FontSize="16" FontFamily="Assets/sui generis rg.ttf#Sui Generis" Margin="0,20,0,0"/&gt;
          &lt;TextBlock Text="Pip pro Wurf" Grid.Row="12" FontSize="16" FontFamily="Assets/sui generis rg.ttf#Sui Generis" Margin="0,20,0,0"/&gt;
          &lt;TextBlock Text="Eröffnungen gewonnen" Grid.Row="13" FontSize="16" FontFamily="Assets/sui generis rg.ttf#Sui Generis" Margin="0,20,0,0"/&gt;
          &lt;TextBlock Text="Anzahl Päsche" Grid.Row="14" FontSize="16" FontFamily="Assets/sui generis rg.ttf#Sui Generis" Margin="0,20,0,0"/&gt;
          &lt;TextBlock Text="Zwei Päsche hintereinander" Grid.Row="15" FontSize="16" FontFamily="Assets/sui generis rg.ttf#Sui Generis" Margin="0,20,0,0"/&gt;
          &lt;TextBlock Text="Drei Päsche hintereinander" Grid.Row="16" FontSize="16" FontFamily="Assets/sui generis rg.ttf#Sui Generis" Margin="0,20,0,0"/&gt;
          &lt;TextBlock Text="Vier Päsche hintereinander" Grid.Row="17" FontSize="16" FontFamily="Assets/sui generis rg.ttf#Sui Generis" Margin="0,20,0,0"/&gt;
          &lt;TextBlock Text="Fünf Päsche hintereinander" Grid.Row="18" FontSize="16" FontFamily="Assets/sui generis rg.ttf#Sui Generis" Margin="0,20,0,0"/&gt;
  
  
        &lt;/Grid&gt;
  
      &lt;/Grid&gt;
   &lt;/Grid&gt;
  </code></pre>
  
  <p>I want to have the absolute Y-position of the Textblock named "Spielstatistik" I already tried things like the following:</p>
  
  <pre><code>float StatisticsNew::GetYPositionFromElement(UIElement^ obj)
  {
  auto transform = obj-&gt;TransformToVisual(nullptr);
  auto point = transform-&gt;TransformPoint(Point(0,0));
  return point.Y;
  }
  
  int YPosition = (int)GetYPositionFromElement(this-&gt;Spielstatistik);
  </code></pre>
  
  <p>YPosition has the value 20. But 20 is just the relative position to the element before (because margin-top is set to 20). </p>
  
  <p><em>How do I get the <strong>absolute</strong> position of the element?</em></p>