I have a grid with 5 cols and 10 rows and in each column the values should be 0-9 on click on the any number I have
to get the value of the clicked cell. what is the best way to build this ?

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are lots of ways to do this, and without knowing more about the requirements it’s hard to say which one would be best.
One way could be to attach a mouse click listener to the Grid, and in the handler, calculate which cell was clicked.
This is good for performance as there’s only one event listener — but you’d have to make sure that any elements you place on top of the Grid allow click events to bubble up (that is, if they implement a click listener, they should use
e.Handled = false).Another way, if you have UI elements in the Grid cells, would be to attach a click listener to each element in the Grid, and use
clickedElement.GetValue(Grid.RowProperty)to get the row number.Edit You could create a simple 5×10 grid using code-behind like this: