WPF: Same line drawn different?

Posted by stefan.at.wpf on Stack Overflow See other posts from Stack Overflow or by stefan.at.wpf
Published on 2010-03-21T04:18:08Z Indexed on 2010/03/21 4:21 UTC
Read the original article Hit count: 448

Filed under:
|

Hello,

I have a canvas and in it I'm drawing some lines:

for (int i = 1; i >= 100; i++)  
      {  
           // Line  
           LineGeometry line = new LineGeometry();  
           line.StartPoint = new Point(i * 100, 0);  
           line.EndPoint = new Point(i * 100, 100 * 100);  

           // Path
           Path myPath = new Path();
           myPath.Stroke = Brushes.Black;
           myPath.StrokeThickness = 1;

           // Add to canvas
           myPath.Data = line;
           canvas1.Children.Add(myPath);
       }

Well, nothing special, but it makes problems - the lines are drawn different! The canvas is inside a scrollviewer, the following image shows different positions of the canvas, however the lines should look the same? Hell, how is this possible? The code above is the only code I've written by hand and it's the only content in the canvas. Anyone knows why this happens and how to prevent this? Thank you very much! Screenshot: http://www.imagebanana.com/view/c01nrd6i/lines.png

© Stack Overflow or respective owner

Related posts about c#

Related posts about wpf