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

  • SEARCH
  • Home
  • 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 4238416
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:54:07+00:00 2026-05-21T02:54:07+00:00

Greetings, I’m having a Grid to which I add rows and columns according to

  • 0

Greetings,

I’m having a Grid to which I add rows and columns according to data given by the user.

Now I wish to have a event that captures the location of my mouseclick by row and column.
So when I click in column 5 of row 2 I wish to get exactly that information in my code behind.

However all I’m getting so far is args.OriginalSource = {System.Windows.Controls.Grid}

Is there any way to accomplish this?

Xaml:

<Grid Background="White" x:Name="MainSchedular">
    <Grid.RowDefinitions>
        <RowDefinition Height="*" />
        <RowDefinition Height="33" />
    </Grid.RowDefinitions>  
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="33">
        <ColumnDefinition Width="33">
        <ColumnDefinition Width="33">
</Grid>

Code behind:

this.MouseLeftButtonDown += (se, eas) =>
{
    //some code here that captures the row and column position
};
  • 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-05-21T02:54:08+00:00Added an answer on May 21, 2026 at 2:54 am

    In case people are wondering how:
    I’ve managed to do this by creating a button and placing in the top left corner of the Grid.

    Using this button as reference for MouseButtonEventsArgs.GetPosition I can then calculate which row and column I clicked by:

    double rowheigth = 0, columnlength = 0;
    int row = 0, column = 0;
    if (pos.X > this.TheGrid.ColumnDefinitions[0].ActualWidth && pos.Y > this.TheGrid.RowDefinitions[0].ActualHeight)
    {
        while (rowheigth + this.TheGrid.RowDefinitions[row].ActualHeight < pos.Y)
        {
            rowheigth += this.TheGrid.RowDefinitions[row].ActualHeight;
            row++;
        }
        while (columnlength + this.TheGrid.ColumnDefinitions[column].ActualWidth < pos.X)
        {
            columnlength += this.TheGrid.ColumnDefinitions[column].ActualWidth;
            column++;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings, I have a particular object which can be constructed from a file, as
Greetings. I have an 2-D array of size [N][N] which will represent a rectangular
Greetings I have an ajax call which: Gets an xml file of posts Populates
Greetings, I have three TS variables resembling something like the following: data <- read.csv(...)
Greetings, I have a complicated scenario to handle. I have a wsdl file which
Greetings all, Is there a built in way to know when a user is
greetings all i have a domain class named car and i have an object
Greetings, I have an asp.net mvc application. I have some links that corresponds to
Greetings I've been working on a homework in which I must create a linked
Greetings, I've taken over from a prior team and writing ETL jobs which process

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.