Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I draw a path with markers (Segments connection points)?

I know how to draw a path in WPF by using the Path Geometry and
Stream Geometry .

I want to add a marker to each connection point in a manner similar to Matlab: enter image description here

I can do a lot of small triangle geometries per marker, but is there a better way?

like image 293
Andrey Rubshtein Avatar asked Dec 30 '25 02:12

Andrey Rubshtein


1 Answers

I would probably do this by overriding OnRender in your chart UserControl and drawing the path first, then markers second.

See this related question.

In it the poster creates a Geometry to represent a triangle then uses the rendering context passed in to OnRender to draw the triangle repeatedly.

You might find if you have a large number of datapoints this method becomes quite slow. You can experiment instead with multiple small blits of a market bitmap to the rendering context, or using the WriteableBitmap API which provides direct access to bitmap & therefore immediate mode rendering.

Edit: You might also be interested in this answer, which discusses high performance WPF graphics in general.

Best regards,

like image 121
Dr. Andrew Burnett-Thompson Avatar answered Dec 31 '25 18:12

Dr. Andrew Burnett-Thompson