I created 8*8 matrix of button for Minesweeper Game. I need to set click event and name to them. How can I do that? Help please. Also I used canvas to create the grid. Is it the best way to do that?
private void makeGrid()
{
int firstlp,secondlp,position=50;
for (int i = 0; i < 400; i=i+50)
{
for (secondlp = 0; secondlp < 400; secondlp = secondlp + 50)
{
Button lbl = new Button()
{
Content = "",
HorizontalAlignment = HorizontalAlignment.Right,
VerticalAlignment = VerticalAlignment.Center,
HorizontalContentAlignment = HorizontalAlignment.Center,
VerticalContentAlignment = VerticalAlignment.Center,
Height = 50,
Width = 50,
};
jereMy.Children.Add(lbl);
Canvas.SetLeft(lbl, secondlp + 50);
Canvas.SetRight(lbl, secondlp + 50);
Canvas.SetTop(lbl, position);
}
position = position + 50;
}
}