在Windows商店应用中,我有一个包含大量列和行的网格
<Grid x:Name="gridContainer"
Background="Transparent"
Tapped="gridContainer_Tapped">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
...
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
...
</Grid.ColumnDefinitions>
</Grid>
并收听Grid Tapped事件。
private void gridContainer_Tapped(object sender, TappedRoutedEventArgs e)
{
}
是否可以在不添加额外透明元素和跟踪其抽头事件的情况下确定点击哪个列和行?
答案 0 :(得分:0)
如果这些单元格中有任何内容,您可以执行此操作:
private void gridContainer_Tapped(object sender, TappedRoutedEventArgs e)
{
if(e.OriginalSource is FrameworkElement)
{
var col = Grid.GetColumn(e.OriginalSource as FrameworkElement);
}
}