Take the 2-minute tour ×

How to get the Grid.Row Grid.Column from the added control?

Basically I have 16 grids with 4 rows and 4 columns, each grid is added a round button.

how to determine which rows and columns the selected round buttons are located respectively in the below MouseEventHandler of mouseover? For mouseclick, there is only round button selected, but for mouseover, there would be a collection of buttons.

RoundButton_MouseEnter, RoundButton_MouseLeave, RoundButton_MouseDown, RoundButton_MouseUp


share|improve this question

1 Answer 1

up vote 4 down vote accepted

You can use Grid.GetColumn(FrameworkElement element) and Grid.GetRow(FrameworkElement element) to find out what row and column an element has been set to. In XAML, Grid.Row="4" is just sugar for Grid.SetRow(element, 4)

share|improve this answer

Your Answer


