private void InitializeGame(Game field) { int x = 0; int y = 0; foreach (Button button in buttonsGrid.Children.OfType <Button>()) { if (x > 2) { x = 0; y++; } Point point = new Point(x, y); FieldItem item = new FieldItem(field, point, button); field.AddField(item); x++; } }