title: How do I get cell row and column indexes of UWP Grid control?
body: <p>I've been trying to get the row index and the column index when specific cell of grid control is tapped. So far nothing...</p>
  
  <p>I achieved to take the absolute value of X and Y when I tap somewhere on the grid control.</p>
  
  <pre><code>private void gridGameBoard_Tapped(object sender, TappedRoutedEventArgs e)
  {
      Grid grd = sender as Grid;
      Point pos = e.GetPosition(grd);
  }
  </code></pre>
  
  <p>I've tried this:</p>
  
  <pre><code>int row = Grid.GetColumn(grd);
  int col = Grid.GetRow(grd);
  </code></pre>
  
  <p>Both gives me only zeros no matter where I tap.</p>
  
  <p>I didn't find another way to take the row and column indexes of the tapped cell...</p>
  
  <p>XAML code:</p>
  
  <pre><code>&lt;Grid Background="Firebrick"&gt;
      &lt;Grid.ColumnDefinitions&gt;
          &lt;ColumnDefinition Width="3*" /&gt;
          &lt;ColumnDefinition Width="1*" /&gt;
      &lt;/Grid.ColumnDefinitions&gt;
  
      &lt;Grid Grid.Column="0" Name="gridGameBoard" Tapped="gridGameBoard_Tapped"&gt;
          &lt;Grid.ColumnDefinitions&gt;
              &lt;ColumnDefinition Width="1*" /&gt;
              &lt;ColumnDefinition Width="1*" /&gt;
              &lt;ColumnDefinition Width="1*" /&gt;
              &lt;ColumnDefinition Width="1*" /&gt;
              &lt;ColumnDefinition Width="1*" /&gt;
              &lt;ColumnDefinition Width="1*" /&gt;
              &lt;ColumnDefinition Width="1*" /&gt;
          &lt;/Grid.ColumnDefinitions&gt;
  
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="1*" /&gt;
              &lt;RowDefinition Height="1*" /&gt;
              &lt;RowDefinition Height="1*" /&gt;
              &lt;RowDefinition Height="1*" /&gt;
              &lt;RowDefinition Height="1*" /&gt;
              &lt;RowDefinition Height="1*" /&gt;
              &lt;RowDefinition Height="1*" /&gt;
          &lt;/Grid.RowDefinitions&gt;
  
          &lt;!-- # # # COLUMN 0 # # # --&gt;
          &lt;Image Grid.Row="0" Grid.Column="0" Source="Assets/box.png" Height="51" Width="69" /&gt;
          &lt;Image Grid.Row="0" Grid.Column="0" Name="img00" VerticalAlignment="Center" HorizontalAlignment="Center" Stretch="None" /&gt;
  
          &lt;Image Grid.Row="1" Grid.Column="0" Source="Assets/box.png" Height="51" Width="69" /&gt;
          &lt;Image Grid.Row="1" Grid.Column="0" Name="img01" VerticalAlignment="Center" HorizontalAlignment="Center" Stretch="None" /&gt;
  
          &lt;Image Grid.Row="2" Grid.Column="0" Source="Assets/box.png" Height="51" Width="69" /&gt;
          &lt;Image Grid.Row="2" Grid.Column="0" Name="img02" VerticalAlignment="Center" HorizontalAlignment="Center" Stretch="None" /&gt;
  
          &lt;Image Grid.Row="3" Grid.Column="0" Source="Assets/box.png" Height="51" Width="69" /&gt;
          &lt;Image Grid.Row="3" Grid.Column="0" Name="img03" VerticalAlignment="Center" HorizontalAlignment="Center" Stretch="None" /&gt;
  
          &lt;Image Grid.Row="4" Grid.Column="0" Source="Assets/box.png" Height="51" Width="69" /&gt;
          &lt;Image Grid.Row="4" Grid.Column="0" Name="img04" VerticalAlignment="Center" HorizontalAlignment="Center" Stretch="None" /&gt;
  
          &lt;Image Grid.Row="5" Grid.Column="0" Source="Assets/box.png" Height="51" Width="69" /&gt;
          &lt;Image Grid.Row="5" Grid.Column="0" Name="img05" VerticalAlignment="Center" HorizontalAlignment="Center" Stretch="None" /&gt;
  
          &lt;!-- # # # COLUMN 1 - 6 are same as COLUMN 0 # # # --&gt;
  
      &lt;/Grid&gt;
  &lt;/Grid&gt;
  </code></pre>