1

i have a screen that shows thousands of points and refresh rate is 10 ms. first i had problem because rendering was slow and jittery. i searched internet people suggest me to convert shapes to visual because shapes have a lot of events and is heavy to render. i changed the points to visuals like this:

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];
}}

the performance still is not acceptable. the question is what is the difference between shapes and FrameworkElement. both have lots of events that make them heavy to render. i want something that doesnt have events. what can i do?!

actually i want to add these visuals to canvas and give them their positions using canvas.setLeft and canvas.setTop. how to do this without inheriting from FrameworkElement?

M.R
  • 11
  • 1
  • 4
  • 1
    You might draw all those points into *one* DrawingVisual, i.e. into the DrawingContext you get from DrawingVisual.RenderOpen(). Start reading [here](http://msdn.microsoft.com/en-us/library/ms742254.aspx). – Clemens Jun 21 '14 at 07:03
  • 2
    You may want to read [this](http://msdn.microsoft.com/en-us/magazine/dd483292.aspx) excellent article by Charles Petzold discusses the same problem. – Suresh Jun 21 '14 at 07:04
  • see if this answer helps you http://stackoverflow.com/questions/23976163/speed-up-adding-objects-to-canvas-in-wpf/23976355#23976355. You may post a working sample of your code, may I try to do it for you. – pushpraj Jun 21 '14 at 09:53

0 Answers0