Line with StrokeThickness = 1 disappears when coordinates are outside its parent grid

218 views Asked by At

I have a Line within a Grid grid with following properties:

internal Line lineHor = new Line { Stroke = new SolidColorBrush(Color.FromRgb(0, 180, 0)), 
StrokeThickness = 1, X1 = 0, X2 = ???, SnapsToDevicePixels = true};

In my case Y1 = Y2 = //somewhere within the height of the grid. Now the Problem appears when X2 is larger than grid.Width, then suddenly the line is not visible anymore. However, if I set StrokeThickness = 2 //or more then it's visible and of the thickness that I set it to so the problem is really only present whenever the thickness is equal to 1.

I tried changing the BitmapScalingMode to NearestNeighbor but nothing changed. Is there some weird rendering going on whenever one of the line's end points is outside its parent?

Hopefully, someone can help me here, because I couldn't find anyone else complaining about this behaviour on StackOverflow or on Google.

0

There are 0 answers