S
S
Sergey2022-02-07 23:56:18
WPF
Sergey, 2022-02-07 23:56:18

How to draw a lot of objects and not fill the memory?

I need to dynamically generate a Canvas background, which should consist of lines for example. For this, you can certainly use the graphic primitives included in the WPF set, but these primitives are stored in RAM, because I can change the properties of these objects, and they will change on the screen, they also track events. But the problem is that when creating a background, there can be quite a lot of such primitives, and you don’t really want to give somewhere 100MB of RAM for background generation.

Is it possible to generate the background of a Canvas element from primitives that won't take up RAM space? Roughly speaking, I want to draw, for example, a line on the Canvas background, and more and more I can’t control it, if I need to change the background, I just redraw it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2022-02-08
@yarosroman

Inherit from Canvas, override OnRender, DrawingContext is passed to it, use it to draw what you need. You can add the properties you need and DependencyProperty to them so that the bindings can be used.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question