0

我正在尝试为多边形指定名称,但是 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;
        }
4

1 回答 1

3

我相信您不能在 Name 属性中使用非法字符,即逗号。尝试改用下划线。

于 2013-01-12T16:56:17.160 回答