我在我的 wpf 应用程序的网格中创建了文本块。我知道如何创建点击事件。但我不确定如何从该单元格获取属性。我想要 Grid.Row 和 Grid.Column 的属性。我怎样才能做到这一点?
<Window x:Class="TicTacToe.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Tic-Tac-Toe" Height="356" Width="475">
<Grid VerticalAlignment="Top" ShowGridLines="True" Height="313" Margin="10,10,2,0">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="o" TextAlignment="Center" FontSize="72" FontFamily="Lucida Bright" FontWeight="Bold"></TextBlock>
<TextBlock Grid.Row="0" Grid.Column="1" MouseLeftButtonDown="ChoosePosition" ></TextBlock>
<TextBlock Grid.Row="0" Grid.Column="2" ></TextBlock>
<TextBlock Grid.Row="1" Grid.Column="0" ></TextBlock>
<TextBlock Grid.Row="1" Grid.Column="1" ></TextBlock>
<TextBlock Grid.Row="1" Grid.Column="2" ></TextBlock>
<TextBlock Grid.Row="2" Grid.Column="0" ></TextBlock>
<TextBlock Grid.Row="2" Grid.Column="1" ></TextBlock>
<TextBlock Grid.Row="2" Grid.Column="2" ></TextBlock>
</Grid>
</Window>
private void ChoosePosition(object sender, MouseButtonEventArgs e)
{
}