WPF canvas performance - children.add invoked many times

I draw a lot of lines on a long canvas (I think striptease), and it tuned quite well for performance, using low-level geometry classes and freezing them, etc. This greatly improved performance, but it still takes several seconds to load several thousand items into the canvas. I did a performance analysis in the application, and it seems like a large percentage of the time is taken by each call canvas.children.add(). I read that this should be an easy call, and since I call it many times one method, he should not try to do something heavy between them ... Maybe there could be some other reason why it could be So a lot of time? And somehow, can I speed it up?

Performance isn't scary, but I'm afraid this might be a problem later when I need to deal with larger datasets.

Just for reference, it looks like it is called 1,400 times in this example, and it takes almost 3 seconds of processor time on a modern / fast laptop.

The canvas is contained in a hierarchy of other controls, so I wonder if they can contribute to this.

Additional note. I also do not set a specific height on the canvas, as it is configured to fill the parent grid container. Could this be a source of problems?

+5
source share
3 answers

, Children.Add , StreamGeometry. : , . , 1400 200 7 7 . , , , , DrawingVisual

+4

, , :

, , , - Measuer/Arrange . , , , . - , StreamGeomatry - , , streamgeormatry .

+1

, , . ( ).

:

WPF 0,5 ?

0

All Articles