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?
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);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.