Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Silverlight事件处理程序响应非常慢_C#_Silverlight_Event Handling - Fatal编程技术网

C# Silverlight事件处理程序响应非常慢

C# Silverlight事件处理程序响应非常慢,c#,silverlight,event-handling,C#,Silverlight,Event Handling,我正在创建一个动态六角网格,8列10个六角,其中一个椭圆以随机六角为中心 我原本以为事件处理程序没有加载。现在看来,他们正在加载,但反应非常缓慢。当我在一两分钟后将鼠标移到生成的网格上时,十六进制开始随机填充,工具提示开始显示(但直到该十六进制的事件处理程序响应)。实际上,最后一个十六进制需要几分钟才能响应鼠标悬停事件 private void CreateHexGrid(int columns, int rows, double length) { //I cr

我正在创建一个动态六角网格,8列10个六角,其中一个椭圆以随机六角为中心

我原本以为事件处理程序没有加载。现在看来,他们正在加载,但反应非常缓慢。当我在一两分钟后将鼠标移到生成的网格上时,十六进制开始随机填充,工具提示开始显示(但直到该十六进制的事件处理程序响应)。实际上,最后一个十六进制需要几分钟才能响应鼠标悬停事件

     private void CreateHexGrid(int columns, int rows, double length)
    {
       //I create a jagged array of points, 
       //hexpoint[# of columns, # of rows, 6 points]
       //the base (0,0) hex is generated point by point 
       //mathematically based on the length of one side 
       //then each subsequent hex is mathematically
       //created based on the points of the previous hex.
       //Finally, I instantiate each Polygon hex and fill 
       //its points collection using the array.
              PointCollection points = new PointCollection();
              SolidColorBrush blackBrush = new SolidColorBrush(Colors.Black);
              SolidColorBrush clearBrush = new SolidColorBrush(Colors.Transparent);
              Polygon hex = new Polygon();
              hex.Stroke = blackBrush;
              hex.StrokeThickness = 1;
              hex.Name = "Hex" + column.ToString() + row.ToString();

              for (int point = 0; point < 6; point++)
               {
                  points.Add(HexPoint[column, row, point]);
               }

              hex.Points = points;
              ToolTipService.SetToolTip(hex, hex.Name);
              hex.MouseEnter += new MouseEventHandler(hex_MouseEnter);
              cnvsHexGrid.Children.Add(hex);
       //....
     }

我做错了什么导致了如此缓慢、缓慢、缓慢的反应?

在Load\u Main中添加处理程序似乎有助于解决这个问题。

作为后续,如果我注释掉事件处理程序,无论我等待多长时间,工具提示都将停止工作。我已经在几个浏览器中测试过了,结果是一样的
    void hex_MouseEnter(object sender, MouseEventArgs e)
    {
        var hex = sender as Polygon;
        SolidColorBrush blueFill = new SolidColorBrush(Colors.Blue);
        hex.Fill = blueFill;
    }