Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 20th, 2010, 09:54 PM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 101
Thanks: 0
Thanked 1 Time in 1 Post
Default How do you draw a line on a canvas in WPF that is 1 pixel thick?

How do you draw a line on a canvas in WPF that is 1 pixel thick?
This is the method I am using for drawing a line on a canvas in WPF that uses the line class set to 1 pixel thick but it actually draws a line that is two pixels thick:
Code:
            Line myLine = new Line();
Code:
            myLine.Stroke = System.Windows.Media.Brushes.Black;
            myLine.X1 = 100;
            myLine.X2 = 140;  
            myLine.Y1 = 200;
            myLine.Y2 = 200;
            myLine.StrokeThickness = 1;
            
            graphSurface.Children.Add(myLine);

Microsoft might have decided to set a standard for line thickness and the minimum is 2 pixels thick when you set the strockThickness to 1, but when you already have rectangles drawn in XAML and even error fonts using WingDings, it is an obvious miss-match. How do you draw a line that is truly 1 pixel thick?

I tried:
myLine.StrokeThickness = 0.5;
but that only makes the line burry.
Is there some sort of setting I need to make in the grid instead?





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to draw indicator line in owc line chart AlexOo General .NET 0 July 9th, 2007 10:32 PM
Draw an "elastic" line zerna Visual C++ 0 March 5th, 2007 11:15 AM
draw line hussar91404 C# 1 August 11th, 2006 03:23 AM
Draw Line talktorajeev C# 1 May 18th, 2006 08:35 AM
Draw Line from coordinates marcin2k Access VBA 1 October 14th, 2005 01:41 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.