I have a 10×10 Grid. And in each space I have added a label to which I added a mousedoubleclick event handler. So when I double click the label it’s supposed to show the Row and Column number, but I only get 0 for both properties.
This is the code… (and yes I have set Grid.SetRow and Grid.SetColumn for each label)
private void grid_Checked(object sender, MouseButtonEventArgs e)
{
MessageBox.Show(Grid.GetRow(e.Source as UIElement).ToString());
}
Are you sure that everything is hooked up correctly? The following works for me:
XAML:
C#:
The
MessageBoxcontains the correct row and column when I click on one of the labels.