In WPF, how can I determine which column / row in the grid is in the control?

I am building the grid dynamically and putting the buttons in one of the columns. When I click the button, I want to know which line of my grid. How can I find this?

+4
source share
1 answer

In the Click event handler for the button, you say:

int row; Button btn = sender as Button; if (btn != null) { row = Grid.GetRow(btn); // And you have the row number... } else { // A nasty error occurred... } 
+12
source

All Articles