How to determine if a certain cell is empty in a Grid?

    1 answer 1

    something like this?

    static bool AnyInCell(Grid grid, int x , int y ) { foreach (UIElement elem in grid.Children) { int fromX = Grid.GetColumn(elem); int toX = fromX + Grid.GetColumnSpan(elem) - 1; int fromY = Grid.GetRow(elem); int toY = fromY + Grid.GetRowSpan(elem) - 1; if (fromX <= x && x <= toX && fromY <= y && y <= toY) return true; } return false; }