Once the added button in grid(window control Grid, not Gridview or datagrid) is clicked, how to find which row and column the button is located in the grid event handler, like click event or some other events? Not the button click event handler
#region Grid event handler setup
myGrid.MouseEnter += new MouseEventHandler(myGrid_MouseEnter);
myGrid.MouseLeave += new MouseEventHandler(myGrid_MouseLeave);
myGrid.MouseDown += new MouseButtonEventHandler(myGrid_MouseDown);
myGrid.MouseUp += new MouseButtonEventHandler(myGrid_MouseUp);
#endregion
Thanks
I notice that Boyan has some solution for the button click event handler case
In WPF, how can I determine what column/row in a grid a control is in?
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...
}
See InputHitTest():