|
-
January 28th, 2008, 07:30 PM
#1
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.
-
January 29th, 2008, 10:19 PM
#2
-
February 5th, 2008, 04:14 PM
#3
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?
-
February 18th, 2008, 05:59 PM
#4
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...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|