I’m drawing a graph in a WPF application, but lines drawn using drawingContext.DrawLine(...) are drawn to sub-pixel boundaries.
I’m able to get them to look nice by creating Line objects, but I don’t want to create tens of thousands of those every time the visual is invalidated.
How can I force them to fit to pixels?
You may draw the lines into a derived DrawingVisual that has the protected VisualEdgeMode property set to
EdgeMode.Aliased:Strange enough, but calling
RenderOptions.SetEdgeMode(visual, EdgeMode.Aliased)on a non-derived DrawingVisual doesn’t do the job.