Line Line Line Class

Definition

Draws a straight line between two points.

public : sealed class Line : Shape, ILinepublic sealed class Line : Shape, ILinePublic NotInheritable Class Line Inherits Shape Implements ILine
<Line .../>
Inheritance
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Inherited Members

Inherited properties

Inherited events

Inherited methods

Examples

This example shows how to use the Line class to create three lines.

<Canvas Height="300" Width="300">
  <!- - Draws a diagonal line from (10,10) to (50,50). - ->
  <Line
    X1="10" Y1="10"
    X2="50" Y2="50"
    Stroke="Black"
    StrokeThickness="4" />

  <!- - Draws a diagonal line from (10,10) to (50,50)
       and moves it 100 pixels to the right. - ->
  <Line
    X1="10" Y1="10"
    X2="50" Y2="50"
    Stroke="Blue"
    StrokeThickness="4"
    Canvas.Left="100"/>

  <!- - Draws a horizontal line from (10,60) to (150,60). - ->
  <Line
     X1="10" Y1="60"
     X2="150" Y2="60"
     Stroke="Black"
     StrokeThickness="4"/>

</Canvas>

Remarks

Set the Stroke to specify the color of the line. Set the StrokeThickness property to specify the thickness of the line.

Constructors

Line() Line() Line()

Initializes a new instance of the Line class.

public : Line()public Line()Public Sub New()
Attributes

Properties

X1 X1 X1

Gets or sets the x-coordinate of the Line start point.

public : double X1 { get; set; }public double X1 { get; set; }Public ReadWrite Property X1 As double
<Line X1="double"/>
Value
double double double

The x-coordinate for the start point of the line, in pixels. The default is 0.

Attributes

X1Property X1Property X1Property

Identifies the X1 dependency property.

public : static DependencyProperty X1Property { get; }public static DependencyProperty X1Property { get; }Public Static ReadOnly Property X1Property As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the X1 dependency property.

Attributes

X2 X2 X2

Gets or sets the x-coordinate of the Line end point.

public : double X2 { get; set; }public double X2 { get; set; }Public ReadWrite Property X2 As double
<Line X2="double"/>
Value
double double double

The x-coordinate for the end point of the line, in pixels. The default is 0.

Attributes

X2Property X2Property X2Property

Identifies the X2 dependency property.

public : static DependencyProperty X2Property { get; }public static DependencyProperty X2Property { get; }Public Static ReadOnly Property X2Property As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the X2 dependency property.

Attributes

Y1 Y1 Y1

Gets or sets the y-coordinate of the Line start point.

public : double Y1 { get; set; }public double Y1 { get; set; }Public ReadWrite Property Y1 As double
<Line Y1="double"/>
Value
double double double

The y-coordinate for the start point of the line, in pixels. The default is 0.

Attributes

Y1Property Y1Property Y1Property

Identifies the Y1 dependency property.

public : static DependencyProperty Y1Property { get; }public static DependencyProperty Y1Property { get; }Public Static ReadOnly Property Y1Property As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the Y1 dependency property.

Attributes

Y2 Y2 Y2

Gets or sets the y-coordinate of the Line end point.

public : double Y2 { get; set; }public double Y2 { get; set; }Public ReadWrite Property Y2 As double
<Line Y2="double"/>
Value
double double double

The y-coordinate for the end point of the line, in pixels. The default is 0.

Attributes

Y2Property Y2Property Y2Property

Identifies the Y2 dependency property.

public : static DependencyProperty Y2Property { get; }public static DependencyProperty Y2Property { get; }Public Static ReadOnly Property Y2Property As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the Y2 dependency property.

Attributes

See Also