开发者

WP7 silverlight grid

In order to learn silverlight on WP7 I'm playing with it around and well, I can't say I'm having sweet times here. I'm developing a simple, yet ugly Mine game (like windows's ^^).

The problem is that I'开发者_运维知识库m gonna use a button for each case on the mines board, but I can't manage to find a way to preview a grid with cells containing my buttons.

I took the Grid component and I'm digging its properties but can't find a way to get a cell and set the button I want it to render, I've seen the RowDefinition/ColumnDefinition collections but I need cells not rows/columns, how could I render a grid of buttons guys ?

Maybe another component I could use ? PS: the size of my mine board is dynamic


The cells don't really exist in XAML. When you define a button, you simply need to tell it where to sit.

<button x:Name="button0_0" Grid.Row="0" Grid.Col="0" />

This will be a button in the top left corner (it is a 0 indexed double array).


Having written some basic games for WP7, I would recommend that you use a canvas instead of a grid, and then tile the buttons as children of the canvas dynamically in codebehind, where you set the buttons ID to be a location (x_y or something like that) and location is dynamic based on the values of x and y.

This works well for me for 2D top down tiles, which is basically what you are trying to do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜