1

In a windows store app I have a grid with a lot of columns and rows

        <Grid x:Name="gridContainer" 
              Background="Transparent"
              Tapped="gridContainer_Tapped">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
                ...
            </Grid.RowDefinitions>

            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                ...
            </Grid.ColumnDefinitions>
       </Grid>

and listening to Grid Tapped event.

private void gridContainer_Tapped(object sender, TappedRoutedEventArgs e)
{

}

Is it possible to determine which column and row was tapped without adding additinal transparet elements and tracking their tapped events?

4
  • You are giving the tap event for entire grid then how do you get the which row tapped?? are you binding any data for that rows and columns??
    – KiShOrE
    May 6, 2015 at 11:21
  • "You are giving the tap event for entire grid then how do you get the which row tapped?" I asked exactly the same question ... May 6, 2015 at 14:57
  • i think that's only possible if you get coordinates of tap input on the grid and measure that with coordinates of Grid and it's row-columns..! Other than that, i'm not seeing any possibility.. May 7, 2015 at 12:47
  • I solved my problem by adding invisible controls and listenting to their Tapped event, but still think it will be very helpful if the Grid.Tapped EventArgs has the tapped Column and Row :) May 7, 2015 at 12:53

1 Answer 1

0

If you have anything inside those cells you can do this:

private void gridContainer_Tapped(object sender, TappedRoutedEventArgs e)
{
   if(e.OriginalSource is FrameworkElement)
   {
      var col = Grid.GetColumn(e.OriginalSource as FrameworkElement);
   }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.