1

我有一个显示数千点的屏幕,刷新率为 10 毫秒。首先我遇到了问题,因为渲染速度很慢而且很紧张。我搜索了互联网人们建议我将形状转换为视觉形状,因为形状有很多事件并且渲染起来很重。我将点更改为这样的视觉效果:

public class MyVisualHost : FrameworkElement{
// Create a collection of child visual objects. 
private VisualCollection _children;

public MyVisualHost()
{
    _children = new VisualCollection(this);
    ...
}

// Provide a required override for the VisualChildrenCount property. 

protected override int VisualChildrenCount
{
    get { return _children.Count; }
}

// Provide a required override for the GetVisualChild method. 

protected override Visual GetVisualChild(int index)
{
    if (index < 0 || index >= _children.Count)
    {
        throw new ArgumentOutOfRangeException();
    }

    return _children[index];
}}

性能仍然不能接受。问题是形状和 FrameworkElement 之间有什么区别。两者都有很多使它们难以渲染的事件。我想要一些没有事件的东西。我能做些什么?!

实际上我想将这些视觉效果添加到画布上,并使用 canvas.setLeft 和 canvas.setTop 为它们提供位置。如何在不继承 FrameworkElement 的情况下做到这一点?

4

0 回答 0