Line Line Line Class

Draws a straight line between two points.

Syntax

Declaration

public sealed class Linepublic sealed class LinePublic NotInheritable Class Line
<Line .../>

Inheritance Hierarchy

Inherited Members

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
Tag
Tag
Tag
, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Remarks

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

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>

Constructors summary

Initializes a new instance of the Line class.

Properties summary

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

Identifies the X1 dependency property.

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

Identifies the X2 dependency property.

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

Identifies the Y1 dependency property.

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

Identifies the Y2 dependency property.

Constructors

  • Line()
    Line()
    Line()
    Line()

    Initializes a new instance of the Line class.

    public Line()public Line()Public Function Line() As

Properties

  • X1
    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"/>
    

    Property Value

    • double
      double
      double

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

  • X1Property
    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

    Property Value

  • X2
    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"/>
    

    Property Value

    • double
      double
      double

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

  • X2Property
    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

    Property Value

  • Y1
    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"/>
    

    Property Value

    • double
      double
      double

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

  • Y1Property
    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

    Property Value

  • Y2
    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"/>
    

    Property Value

    • double
      double
      double

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

  • Y2Property
    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

    Property Value

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.StaticAttribute
Windows.Foundation.Metadata.ActivatableAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.ThreadingAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.WebHostHiddenAttribute

Details

Assembly

Windows.UI.Xaml.Shapes.dll