-
Grid of buttons
I want to have an 8x8 array of square buttons, all equal size. The buttons should be created and placed in the cells of the grid by the code.
Each button should have a specified background color, and sometimes an image. The image has a transparent background so the button background color shows through the transparent parts.
All buttons will share an event handler, which should be able to determine which cell (row, col) the button is located. I could probably put that information in the button's tag if I need.
-
Re: Grid of buttons
-
Re: Grid of buttons
I had accomplished this in VB.Net forms application, but I want to do the same thing in WPF. But I'm running into several obstacles, such as placing the buttons in the appropriate cells (specified by row and column), and setting the background color and image properties of the buttons.
What's the best control to use to contain the buttons?
-
Re: Grid of buttons
For Silverlight 1.1
There is no prebuilt grid control
So I would manage the placement manually.
For the callback, I would populate the Button.Tag field with data defining its location within the grid, then use (Button)sender.Tag to get the data in the call back function.
psudocode:
placebtn(x,y)
{
b = new button
b.setx = x
b.sety = y
b.text = "bla"
b.tag=new point(x,y);
b.onclick(clickfunction)
}
clickFunction(sender, e)
{
pos = (Point)((Button)sender.Tag);
}
Hope it helps...