Search code examples
c#wpfgeometrylineframeworkelement

Line disappearing when pen thickness is very small


I'm developing an application that draws geometry elements like lines, etc. on a FrameworkElement. The lines, etc. are implemented as GeometryDrawing. As I want to preserve the line thickness at any (possible) zoom level, there is a routine that adapts the line thickness to the current zoom level and the size of the visible geometry.

Now I encounter a problem: At high zoom factors (like 490) - and thus resulting very low pen thicknesses like 0.010 - horizontal and vertical lines disappear. All other lines are not affected.

I already tried to set the SnapsToDevicePixels property of the FrameworkElement I'm drawing on to true but with no effect.


Solution

  • After a bit of research I found this thread: Horizontal or vertical WPF Lines limited to 125,000 pixels?

    So it seems that it is a bug in WPF if the line gets too long while being too thin...