views:

102

answers:

1

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

Thanks

+3  A: 

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)

Matt Greer