Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8924017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:17:25+00:00 2026-06-15T07:17:25+00:00

I have create textblocks in my grid in my wpf application. I know how

  • 0

I have create textblocks in my grid in my wpf application. I know how to create the click event. But I’m not sure how to get properties from that cell. The properties I want Grid.Row and Grid.Column. How can I do this?

<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)
        {
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T07:17:26+00:00Added an answer on June 15, 2026 at 7:17 am

    As Grid.Row and Grid.Column are attached properties from the Grid class, you can get them using this syntax:

    int row = Grid.GetRow(myTextBox);
    int column = Grid.GetColumn(myTextBox);
    

    In your case, you can cast the sender argument in the Click handler, so it would look like this:

    var myTextBox = sender as TextBox;
    if(myTextBox != null) {
       int row = Grid.GetRow(myTextBox);
       int column = Grid.GetColumn(myTextBox);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I may have missed something obvious with WPF, but is it possible to create
The WPF application I've created contains a Grid with 3 rows. I have a
I am trying to create a user control within a WPF application that will
I have a WPF Grid and a list of values. The list of values
I'd like to create a custom validator template for my WPF app. I have
I have a grid with repeated columns with same style but different names the
I have a slow data source, so I create it asynchronously. Also, many properties
I'm fairly new to WPF, and I want to create an MVVM based application
I have a WPF treeview. Here is the code: <DockPanel Grid.Row=2 Margin=0,6,0,0 Grid.RowSpan=5 Height=491
I have a WPF page. Page has some content, but the last child component

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.