相关疑难解决方法(0)

如何在0.5秒内用WPF画出数万个点?

我正在编写WPF代码来显示实时情节,这是一条包含大约10,000点的连线.在我的电脑中显示图片大约需要5秒钟.有没有人有想法让它更快,并在0.5秒内?

class eee : FrameworkElement
{

    public eee()
    {
        _children = new VisualCollection(this);
        Random rand = new Random();
        DrawingVisual dv = new DrawingVisual();
        using (DrawingContext dx = dv.RenderOpen())
        {
            Pen drawingPen = new Pen(Brushes.Black, 1);
            double x=rand.Next(300);
            double y = rand.Next(300);
            for (double i = 0; i < 1000; i = i + 0.1)
            {
                y = 100 + rand.Next(100);
                dx.DrawLine(drawingPen, new Point(i, x), new Point(i + 1, y));
                x = y;
            }
        }
         _children.Add(dv);
    }
Run Code Online (Sandbox Code Playgroud)

c# wpf performance templates itemscontrol

21
推荐指数
1
解决办法
2万
查看次数

标签 统计

c# ×1

itemscontrol ×1

performance ×1

templates ×1

wpf ×1