(X) Hide this
    • Login
    • Join
      • Generate New Image
        By clicking 'Register' you accept the terms of use .

Tip: How to draw a line?

(1 votes)
Martin Mihaylov
>
Martin Mihaylov
Joined Oct 29, 2007
Articles:   50
Comments:   70
More Articles
0 comments   /   posted on Sep 05, 2008
Tags:   line , martin-mihaylov
Categories:   General , Design

You can draw a line decleratively in the Xaml or dynamically in the codebehind. Here it is how it's done in the both ways:

Xaml

<Line x:Name="MyLine" X1="0" Y1="0" X2="100" Y2="100" Stroke="Yellow" StrokeThickness="2" />

C#

Line myLine = new Line();
myLine.X1 = 0;
myLine.Y1 = 0;
myLine.X2 = 100;
myLine.Y2 = 100;
myLine.Stroke = new SolidColorBrush( Colors.Yellow );
myLine.StrokeThickness = 2;

X1 and Y1 represent the start point of the line and X2 and Y2 - the end point. With the Stroke and StrokeThickness properties we define the color and the thickness of the line.

That's it!


Subscribe

Comments

No comments

Add Comment

Login to comment:
  *      *