我正在尝试为多边形指定名称,但是 Visual Studio 一直给我一个例外:
'The invocation of the constructor on type 'Isometric_Turtle_Simulator.MainWindow' that matches the specified binding constraints threw an exception.' Line number '3' and line position '9'.
我的代码是:
for (int a = 0; a < z; a++)
{
for (int b = 0; b < x; b++)
{
for (int c = 0; c < y; c++)
{
tile = getTile.genTile(worldData[a,b,c]);
tile.Name = a.ToString() + "," + b.ToString() + "," + c.ToString();
Canvas.SetTop(tile, posY);
Canvas.SetLeft(tile, posX);
mainCanvas.Children.Add(tile);
tile.MouseDown += (sender, e) => mouseDownEvent(sender, e);
posY = posY + 15;
posX = posX + 30;
}
posY = posY - 15 * (x - 1);
posX = posX - 30 * (y + 1);
}
posX = posXOrigin;
posY = posY - (35 + (15 * x));
Height = Height + 35;
mainCanvas.Height = Height;
}