简体   繁体   中英

WP7 Grid Position

I really need help on this, I have a 9x9 grid in WP7, with gridlines. I have a character in each of the grid "cell".

How could I retrieve the position in the grid using [,] or any other means? Hopefully I can get the position through: grid[col, row]

I tried using this: char[,] grid = new char[numColumnsToAdd, numRowsToAdd];

But it didn't work.

Thanks.

I would generally recommend to only use grid cells and rows for layout purposes and not to track the current row/cell. But since you are already doing this, I would simply track clicks on each control (eg Label) via a single event handler. Then, simply check the row or cell via:

object row = ((TextBlock)sender).GetValue(Grid.RowProperty);
object cell = ((TextBlock)sender).GetValue(Grid.CellProperty);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM