Как определить пустая ли определенная ячейка в Grid?
1 ответ
как-то так?
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;
}